each_with_index
在 ruby 1.8.7 中的集合上使用时,如何指定从哪个索引开始?
collection.each_with_index do |element, index = 1|
#do smth
end
像这样使用它会产生以下错误:
syntax error, unexpected '=', expecting '|'
collection.each_with_index do |element, i = 1|
each_with_index
在 ruby 1.8.7 中的集合上使用时,如何指定从哪个索引开始?
collection.each_with_index do |element, index = 1|
#do smth
end
像这样使用它会产生以下错误:
syntax error, unexpected '=', expecting '|'
collection.each_with_index do |element, i = 1|