Skip to content

Instantly share code, notes, and snippets.

# use inner_array for index
mapped_array = array.inject([]){|inner_array, value| inner_array << map_op(value, inner_array.size)}
#as long as each iteration pushes one item on to the inner_array