Finding position of a value in an array

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 31 14:47:02 UTC 2019


On 12/31/19 9:41 AM, Steven Schveighoffer wrote:

> import std.stdio;
> import std.algorithm;
> import bufref;
> 
> void main()
> {
>      string x = "hello, world!";
>      writeln(x.bwin.find('o').bufRef.pos);
> }

for the original example:

     int[] a = [77,66,55,44];
     int i = a.bwin.find(55).bufRef.pos;
     assert(i == 2);

-Steve


More information about the Digitalmars-d-learn mailing list