Map With Index Over An Array
[1,2,3].map { |item| item * item }
#=> [1,4,9][1,2,3].map.with_index { |item, index| item * index }
#=> [0,2,6][1,2,3].map.with_index(1) { |item, index| item * index }
#=> [1,4,9]Last updated
[1,2,3].map { |item| item * item }
#=> [1,4,9][1,2,3].map.with_index { |item, index| item * index }
#=> [0,2,6][1,2,3].map.with_index(1) { |item, index| item * index }
#=> [1,4,9]Last updated