Why does this map expression produce different results depending on whether I use braces or do/end?
a = [1,2,3,4,5] p a.map { |n| n*2 } #=> [2,4,6
With the do/end syntax you are passing the block to p as a second argument, rather than to the map. You get the same result with:
do/end
p
p a.map
The block is ignored by p as it does not produce anything on inspect.
inspect