3 ms·
The general convention is that {} is for one line blocks, and do/end for multiline. [1,2,3].each{|n| puts n } versus [1,2,3].each do |n| m = n
by steveklabnik 16y ago
The general convention is that {} is for one line blocks, and do/end for multiline.
[1,2,3].each{|n| puts n }
versus
[1,2,3].each do |n|
m = n + 1
puts m
end
The reason? do/end is much prettier than {}, but {} is really nice for chaining...
[1,3,2].collect{|n| n + 2 }.sort