Array#find_index
allows you to find the index of the first item that either
- is equal to an
object
, or - makes a block passed to it evaluate to true
Array#rindex
can allow you to find the index of the last item that is equal to an object
, but is there anything that allows you to find the index of the last item that makes a block passed to it return true?
Otherwise, should I do something like
last_index = array.length - 1 - array.reverse.find_index{|item| item.is_wanted?}