Favorites

Geek Mama 2013-05-23

This is one of my very favorite ruby tricks that I use every day:

irb(main):007:0> a = [1, 2, 3] => [1, 2, 3] irb(main):008:0> x, y, z = a.collect{|i| i * 2 } => [2, 4, 6] irb(main):009:0> x => 2 irb(main):010:0> y => 4 irb(main):011:0> z => 6