Find a char among string (string.findAmong.char)
Mike Parker
aldacron at gmail.com
Tue Jul 6 12:08:11 UTC 2021
On Tuesday, 6 July 2021 at 11:35:14 UTC, BoQsc wrote:
> I tried out .canFind method, and to test it I removed the
> letter 'o' from the Alphabet.
> Weirdly enough .canFind method still found 'o' letter among the
> Alphabet.
>
> https://run.dlang.io/is/2Fvenf
Looks like it has something to do with the alias. Static arrays
aren't ranges, so you should really be seeing the same error you
would if you passed `letters` directly.
Change the `canFind` call to take a slice of the array:
```d
if (letters[].canFind(letter)){
```
And it outputs the following as expected:
```
k letter is found among the alphabet.
```
This warrants a bug report with a minimized example.
More information about the Digitalmars-d-learn
mailing list