I can't find out which method to use for finding the last element of an array matching a condition.
This should work but that doesn't seems to be the best way:
array.reverse.find {condition}
array[array.rindex {condition}]
Would expect something like array.rfind {condition}...
array.rindex(condition)
will give the last matching element index no.
This will give you last matching element
array[array.rindex(condition)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With