Logo

Programming-Idioms

History of Idiom 222 > diff from v4 to v5

Edit summary for version 5 :
New Ruby implementation by user [steenslag]

Version 4

2020-04-06, 21:38:37

Version 5

2020-04-06, 22:58:52

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Idiom #222 Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

Extra Keywords
position
Extra Keywords
position
Code
i = items.index(x) || -1