Find a char among string (string.findAmong.char)

BoQsc vaidas.boqsc at gmail.com
Tue Jul 6 16:00:17 UTC 2021


On Tuesday, 6 July 2021 at 15:48:35 UTC, rassoc wrote:
> You can also do:
>
> ```d
> import std;
> void main()
> {
>     // https://dlang.org/phobos/std_ascii.html#.lowercase
>     "Book.".filter!(c => lowercase.canFind(c))
>            .each!(c => writeln(c, " found"));
>
>     // Output:
>     // o found
> 	// o found
> 	// k found
> }
> ```

I really don't like reading arrow functions.
It takes some more effort to understand, follow and get used to 
them.
I'd like something simple and effortless looking and feeling that 
would make code readable similarly to an english sentence.

Such as this, but as noted, this does not work as 
intended/assumed by me:
```
if (letter.findAmong(alphabet)){
          write("found");
      }
```


More information about the Digitalmars-d-learn mailing list