In the language Ruby the following works in irb
for fruit in ['apple', 'banana', 'cherry', 'date'] do
puts fruit
end
but this one does not
# error
for fruit in ['apple', 'banana', 'cherry', 'date'] { puts fruit }
please note for reference the following block delimiters do not error
5.times do |i|
puts "hello "+i.to_s
end
5.times { |i| puts "hello "+i.to_s }
Edit: I guess what I'm observing is an inconsistency with the way do end is substituted for { } can someone explain why or please point out my mistake?
refine <class> doas well.doin aforloop.forandwhile(which acts likefor) are not methods. But I await a formal reasoning.forandwhileloops in ruby.foris defined in the official Ruby doc. Does somebody know where it is?