Ruby block variants
Ruby blocks come in two variants
{|vars| #code }
do |vars|
#code
end
Once you realize that these are both equivalent blocks, you can do either
(1..3).map{|n| n}.inject(:+)
(1..3).map do |n|
n
end.inject(:+)
Written on May 8, 2015