indexOf

Finds the first element in a range that equals some value

indexOf
(
Range
T
)
(
Range range
,,
size_t fromIndex = 0
)
if (
from!"std.range".isInputRange!Range
)

Parameters

range
Type: Range

an input range

value
Type: T

value to search for

fromIndex
Type: size_t

which index to start searching from

Return Value

Type: auto

An Optional!T

Examples

import optional;
assert([1, 2, 1, 2].indexOf(2) == some(1));
assert([1, 2, 1, 2].indexOf(2, 2) == some(3));
assert([1, 2, 1, 2].indexOf(3) == none);

Meta

Since

0.0.1