Simple string membership test

Sergey kornburn at yandex.ru
Sat Feb 15 18:13:39 UTC 2025


On Saturday, 15 February 2025 at 17:58:44 UTC, Ian wrote:
> Hi,
>
> What's the best (idiomatic) way of checking if a string is in a 
> list of strings:
>
> ```d
> string v = "tofind";
> if (v ismemberof ["abc", "def","tofind"])
>    etc();
> ```
>
> Thanks,
>  ian

canFind or countUntil
https://dlang.org/phobos/std_algorithm_searching.html


More information about the Digitalmars-d-learn mailing list