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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With