Skip to main content
Version: Next

Index Of In List

Gets the index at which the first occurrence of a value in the list

Description

Gets the index at which the first occurrence of value is found in the list. If From Index is negative, it will be used as the offset from the end of the list.

The brick is supposed to be used to find the index in a list of primitive types (like strings, numbers, booleans, or Cloud Object). <b>Date/time and color are complex objects and are not supported</b>

If you need to find the index in a collection of non-primitive types (e.g. objects) or condition is more complex than just a value, it is recommended to use the Find In List brick.

Examples:

  • inputs

    • source = [1, 2, 1, 2]
    • value = 2
    • from index = 0
  • outputs

    • result = 1
  • inputs

    • source = [1, 2, 1, 2]
    • value = 2
    • from index = 2
  • outputs

    • result = 3

Inputs

  • Source (Object): The collection to inspect. Could be in the form of List, Array and QueryResult
  • Value (Object): The value to search for
  • From Index (Number): The index to search from

Outputs

  • Index (Number): The found index or -1 if the value wasn't found
  • Error Flow (Error Flow): Triggered by providing unexpected type of the source