I\'m learning the details of how each works in ruby, and I tried out the following line of code:
each
p [1,2,3,4,5].each { |element| el }
Array#each returns the [array] object it was invoked upon: the result of the block is discarded. Thus if there are no icky side-effects to the original array then nothing will have changed.
Perhaps you mean to use map?
map
p [1,2,3,4,5].map { |i| i*i }