Skip to main content

Pair.index_of

index_ofelementstart

Group: Values

Documentation

Returns the index of an element in the pair. Returns Nothing if the element is not found.

Arguments

  • element: The element to search for or a predicate function to test for each element.
  • start: The index to start searching from. If the index is negative, it is counted from the end of the pair.

Examples

Find the index of an element in a pair.

      Pair.new 1 2 . index_of 2 == 1
Pair.new 2 2 . index_of 2 == 0