About Ruby 19 February 2010 Asian Institute of Technology Bangkok, Thailand Powerful Enumerable Processing irb(main):001:0> nums = (1..12).to_a => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] irb(main):002:0> squares = nums.map { |n| n * n } => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144] irb(main):003:0> evens = nums.select { |n| n % 2 == 0 } => [2, 4, 6, 8, 10, 12] irb(main):004:0> odds = nums - evens => [1, 3, 5, 7, 9, 11] irb(main):005:0> sum = nums.inject { |sum,n| sum += n } => 78