Find the last occurrence of an array value
In Ruby you can use the rindex
method on an array to return the last index the value argument is stored at. For Example:
arr= ['b', 'a', 'a', 'a']
arr.rindex('a')
#=> 3
arr.rindex('b')
#=> 0
Tweet