December 08, 2018 Re: std.algorithm.canFind behavior difference between arrays and elements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Seb | On Friday, 7 December 2018 at 20:28:37 UTC, Seb wrote: > On Friday, 7 December 2018 at 19:38:29 UTC, Arun Chandrasekaran wrote: >> On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: >>> On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: >>>> [...] >>> >>> Alternatively to the answers above you can also use a custom lambda for canFind: >>> >>> https://run.dlang.io/is/QOXYbe >> >> Just curious, how do we find multiple needles? This throws compilation error >> >> assert(hay.canFind!(e => (e.canFind(["111", "222"])))); >> >> An example in the doc would be helpful. > > > It's variadic: https://run.dlang.io/is/AKkKA9 > > Please feel free to add an example to the docs. Sure, here it is https://github.com/dlang/phobos/pull/6796 |
Copyright © 1999-2021 by the D Language Foundation