isPresent

Checks if the given value is present in the given array

@safe @nogc
bool
isPresent
(
T
)
(
T[] array
,)

Parameters

array T[]

the array to check against

value T

the value to check prescence for

Return Value

Type: bool

true if present, false otherwise

Examples

Tests the isPresent!(T)(T[], T) function

Case: Non-empty array

ubyte[] values = [1,2,3];
foreach(ubyte value; values)
{
    assert(isPresent(values, value));
}
assert(isPresent(values, 0) == false);
assert(isPresent(values, 5) == false);

Tests the isPresent!(T)(T[], T) function

Case: Empty array

assert(isPresent([], 1) == false);

Meta