fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 222: Find first index of an element in list
Idiom # 222: Find first index of an element in list
See
programming-idioms.org
:
Code
i := (items.index_of x).get -1
What are effects?
Running Example
ex222 is x0 := 5 items := [1,2,3,4,5,6,7] i0 := (items.index_of x0).or_else -1 say "found $x0 at index $i0" x1 := 55 i1 := (items.index_of x1).or_else -1 say "found $x1 at index $i1"
What are effects?
last changed: 2024-07-01
next: Idiom # 223: for else loop