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

jfondren julian.fondren at gmail.com
Mon Jul 5 18:59:09 UTC 2021


On Monday, 5 July 2021 at 18:53:27 UTC, jfondren wrote:
>
> If you replace the findAmong call with 
> `[letter].findAmong(alphabet)`, this works.

Consider:

```d
import std;

void main() {
     import std.ascii : alphabet = letters;

     string wordExample = "Book.";
     foreach (letter; wordExample) {
         writefln!"%c is %sa letter"(letter, 
[letter].findAmong(alphabet).length ? "" : "not ");
         writefln!"%c is %sa letter"(letter, 
alphabet.canFind(letter) ? "" : "not ");
     }
     writeln("___>>___finally some letters".findAmong(alphabet));
}
```



More information about the Digitalmars-d-learn mailing list