# INDEX\_OF

### Description

`INDEX_OF` returns the zero-based index of the first occurrence of a value in a list or string. If the value is not found, it returns `-1`.

### Syntax

```
INDEX_OF(collection, value)
```

**Returns:** An integer index, or `-1` if not found.

### Example with a list

```
INDEX_OF(['red', 'green', 'blue'], 'green')
```

This returns `1`, since `'green'` is at index 1 (zero-based).

### Example with a string

```
INDEX_OF('Hello World', 'World')
```

This returns `6`, the position where `'World'` begins.

### Example when not found

```
INDEX_OF(['a', 'b', 'c'], 'z')
```

This returns `-1`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atfinity.io/rule-language/operators/list-operators/index_of.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
