好吧,我还没有找到一个干净的解决方案来轻松地用 Ruby 编写这段代码:
# Java style version:
array.each do |i, el|
if i < array.length - 1
process(array[i], array[i+1])
end
end
# Would be nice if I could do something like this:
array.each do |i, el, next|
process(el, next)
end