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

jfondren julian.fondren at gmail.com
Mon Jul 5 19:25:23 UTC 2021


On Monday, 5 July 2021 at 19:19:19 UTC, BoQsc wrote:
> If I use `[letter].findAmong(alphabet)` in my code, it 
> considers a dot (.) punctuation character as a letter.
> You can see it here:
> https://run.dlang.io/is/YWmaXU

It returns a zero-length array that, because it's not null, is 
true. That's why I used .length in my example.

```
$ rdmd --eval 'writeln("str"[$..$].length); writeln("str"[$..$] ? 
true : false)'
0
true
$ rdmd --eval 'writeln([].length); writeln([] ? true : false)'
0
false
```


More information about the Digitalmars-d-learn mailing list