digitalmars.D.learn - Multi-Dimensional Associative Arrays ".get" and "in"
- Paul (6/6) Jun 06 2012 I've seen examples using .get and "in" to test for keys:
- Timon Gehr (10/16) Jun 08 2012 Well, no. string[string][string][string] is an associative array mapping...
I've seen examples using .get and "in" to test for keys: ....aa.get("hello", "salute") == "ciao".... ...."hello" in aa.... Can I use this .get function or "in" operator with multi-D arrays? string[string][string][string] aa; ....if (["hello"][][] in aa).... ?
Jun 06 2012
On 06/06/2012 04:17 PM, Paul wrote:I've seen examples using .get and "in" to test for keys: ....aa.get("hello", "salute") == "ciao".... ...."hello" in aa.... Can I use this .get function or "in" operator with multi-D arrays? string[string][string][string] aa; ....if (["hello"][][] in aa).... ?Well, no. string[string][string][string] is an associative array mapping strings to associative arrays mapping strings to associative arrays mapping strings to strings. The indexes are more or less unrelated as far as the AA interface is concerned. You can implement such functionality yourself, or use an approach like string[Tuple!(string, string, string)] aa; ....if(tuple("hello","salute","ciao") in aa).... if it is compatible with your usage patterns. this maps 3 key strings to the value string in one go.
Jun 08 2012