Search code examples
arraysseqnim-lang

Nim: find the index of an item in an array or sequence


Is there a builtin method to find the index of an item in an array or sequence, equivalent to Python index ? (It may return the index of the first occurrence, or all the indices.)


Solution

  • There's find.

    Returns the first index of item in a or -1 if not found. This requires appropriate items and == operations to work.