Array Search Functions
The array function index-of looks up a value in an array, and the operations any,
all and find-index test the elements of an array against a predicate expression.
Note: These functions are experimental and subject to change. They report “no match” with a
-1orfalseresult; once the language has optional types,index-ofandfind-indexshould return an optional index instead. Tracking issue: slint-ui/slint#12777 ↗.
index-of
Section titled “index-of”array.index-of(value) reads the index of the first element that equals value,
or -1 if the array contains no such element.
export component Example { in-out property<[string]> names: ["Aardvark", "Beaver"]; out property <int> beaver-index: names.index-of("Beaver"); // 1}Syntax
Section titled “Syntax”A predicate expression has the form (name) => condition.
It binds name to a value and evaluates condition, which must be a bool.
The name is in scope only inside condition.
Predicates are passed to the array operations any, all and find-index,
which supply each element in turn as name:
array.any((name) => condition)readstrueifconditionholds for at least one element.array.all((name) => condition)readstrueifconditionholds for every element.array.find-index((name) => condition)reads the index of the first element for whichconditionholds, or-1if no element matches.
The argument name is available only inside the predicate expression, and its type is inferred from the array element type.
any returns false for an empty array, all returns true for an empty array, and
find-index returns -1 for an empty array.
For a plain value-equality lookup, prefer array.index-of(value) over
find-index((name) => name == value): it needs no predicate.
Reach for find-index when the match condition is more than equality against a single value.
Example
Section titled “Example”export component Example { in-out property<[int]> list-of-int: [1, 2, 3];
out property <bool> contains-two: list-of-int.any((value) => value == 2); // true out property <bool> all-positive: list-of-int.all((value) => value > 0); // true out property <int> index-of-first-even: list-of-int.find-index((value) => mod(value, 2) == 0); // 1}Current Limitations
Section titled “Current Limitations”Predicates are the only form of closure in the Slint language, and they are only accepted
as the argument of any, all and find-index.
A predicate cannot be stored in a property, passed to a function or callback, or called directly.
The predicate must be written inline in the call to any, all or find-index;
passing a closure stored in a local variable is rejected with an error.
© 2026 SixtyFPS GmbH