Actually, there're no so big difference. But the priority is difference. We can check an example out as below then we can understand.
my_array = [1, 2, 3, 4, 5]
# <1>
p my_array.map { |item|
item * 2
}
# >> [2, 4, 6, 8, 10]
# <2>
p my_array.map do |item|
item * 2
end
# >> #<Enumerator: [1, 2, 3, 4, 5]:map>
The interpreter will check as like.
p(my_array.map do |item| item * 2 end)
p(my_array.map) do |item| item * 2 end
Most of people said
braces {}
is used inSINGLE LINE
.do..end
is used inMULTI LINE
.