Ordinal array¶ ↑
<img src=“https://codeclimate.com/badge.png” />
Ordinal array is a Gem which allows you to access to a value of an array by an ordinal value. You can access to the first element of an array by the “first” method. Now you can access to the second element by “second”, the third by “third” and that until the 999th elements.
Works with Ruby 1.9
Improve ordinal array speed for multiple calls on the same method on the same array: (Benchmark results: gist.github.com/2337544)
Exemple:
my_array = ["value1", "value2", "value3"] puts my_array.third # print: value 3 puts my_array.third # print: value 3 (But... much faster!)
How to use¶ ↑
Just add gem “ordinal_array” in your gemfile. It provides you some methods on the basic array class
Exemple of use:
my_array = ["value1", "value2", "value3"] puts my_array.third # print: value 3 my_array[41] = "it works fine" puts my_array.fourty_second # print: it works fine
Contributors¶ ↑
*Kevin Disneur