This is the ThingsDB documentation for version v0, click here for the latest version!

index_of

The function returns the first index of the item in a list or tuple that matches the provided value, otherwise nil if it is not present. The index of an array starts at 0, so the first item has index 0 the second 1 and so on.

This function does not generate an event.

Function

array.index_of(value)

Arguments

Argument Type Description
value any The value to find the index for.

Return value

Index at which the first item matches a given value, or nil if it is not present.

Example

This code shows an example using index_of():

["January", "February", "March", "April"].index_of("March");

Return value in JSON format

2