Last updated
Was this helpful?
Last updated
Was this helpful?
Or, including the "extra credit" task:
The :k
adverb tells it to return the key (a.k.a. list index) instead of the value of the matching element.
The :end
adverb tells it to start searching from the end of the list.
If you plan to do many searches on the same large list, you might want to build a search hash first for efficient look-up:
The built-in method .first
takes a , and returns the first matching list element.