Finding position of a value in an array
JN
666total at wp.pl
Mon Dec 30 23:15:48 UTC 2019
On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote:
>
> int i = a.countUntil!(v => v == 55);
> assert(i == 2);
I also had to ask because I couldn't find it. In other languages
it's named "index()", "indexOf()" or "find()". D is the only
language I know which uses the "countUntil" scheme. And even so
it's not obvious from the name if it's the index of the element
or number of preceding elements.
More information about the Digitalmars-d-learn
mailing list