Improving Ruby Array class

Pablo Ifran
April 6, 2009 | 2 min read

Improving the ruby Array class

Many times, when you are iterating over an array you want to know the last or the first element to do something. Unfortunately ruby don’t provide any method to help you doing this task.
So, if you want a trick to do this, you can add this few lines in a rails project inside an initalizer.

Put this code in initializers/array.rb

Get our stories delivered to your inbox weekly.