www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Check if Key exists in Associative Array using D language.

reply BoQsc <vaidas.boqsc gmail.com> writes:
I've found [std.algorithm: canFind][1] to be useful on a 
**regular arrays**.

I'd like to know if there is similar function: that can check if 
a **key** inside a [Associative Array][2] can be found.

[1]:https://dlang.org/phobos/std_algorithm_searching.html#.canFind
[2]:https://dlang.org/spec/hash-map.html
Apr 05 2022
parent reply Dennis <dkorpel gmail.com> writes:
On Tuesday, 5 April 2022 at 11:26:27 UTC, BoQsc wrote:
 I'd like to know if there is similar function: that can check 
 if a **key** inside a [Associative Array][2] can be found.
You can use the `in` operator for that: https://dlang.org/spec/hash-map.html#testing_membership
Apr 05 2022
parent BoQsc <vaidas.boqsc gmail.com> writes:
On Tuesday, 5 April 2022 at 11:53:19 UTC, Dennis wrote:
 On Tuesday, 5 April 2022 at 11:26:27 UTC, BoQsc wrote:
 I'd like to know if there is similar function: that can check 
 if a **key** inside a [Associative Array][2] can be found.
You can use the `in` operator for that: https://dlang.org/spec/hash-map.html#testing_membership
This is brilliant, thank you.
Apr 05 2022