ddash.range.nth

Gets the element at index n of a range

Members

Aliases

first
alias first = from!"ddash.range".maybeFront

Returns optional front of range

last
alias last = from!"ddash.range".maybeBack

Returns optional end of range

Examples

1 import optional: some, none;
2 import ddash.range.front;
3 assert([1, 2].nth(1).frontOr(1) == 2);
4 assert((int[]).init.nth(1).frontOr(9) == 9);
5 
6 assert([1, 2].nth(1) == some(2));
7 assert((int[]).init.nth(1) == none);
8 
9 assert([1, 2, 3].nth!(Yes.wrap)(10) == some(2));

Meta