digitalmars.D.learn - using tuple as value type for associative array
- Flaze07 (10/10) Jun 20 2018 when I do
- Computermatronic (6/16) Jun 20 2018 what["something"].first = 20 will attempt to get an element of
- Flaze07 (2/18) Jun 20 2018 huh, interesting, thanks
when I do Tuple!(uint, "first", uint, "second")[string] what; //I tried aliasing the tuple as well what["something"].first = 20; I get range error but when I do uint[string] what2; what2 = 20; I get none of those range error, so...how do I use tuple as value type for associative array ?
Jun 20 2018
On Thursday, 21 June 2018 at 02:44:12 UTC, Flaze07 wrote:when I do Tuple!(uint, "first", uint, "second")[string] what; //I tried aliasing the tuple as well what["something"].first = 20; I get range error but when I do uint[string] what2; what2 = 20; I get none of those range error, so...how do I use tuple as value type for associative array ?what["something"].first = 20 will attempt to get an element of what, then assign a member, while what2["something"] = 20 will add an element to what2 with the value of 20. Since what["something"] is not present, it will throw a range error. Try what["something"] = tuple(20, 0); instead.
Jun 20 2018
On Thursday, 21 June 2018 at 03:04:46 UTC, Computermatronic wrote:On Thursday, 21 June 2018 at 02:44:12 UTC, Flaze07 wrote:huh, interesting, thankswhen I do Tuple!(uint, "first", uint, "second")[string] what; //I tried aliasing the tuple as well what["something"].first = 20; I get range error but when I do uint[string] what2; what2 = 20; I get none of those range error, so...how do I use tuple as value type for associative array ?what["something"].first = 20 will attempt to get an element of what, then assign a member, while what2["something"] = 20 will add an element to what2 with the value of 20. Since what["something"] is not present, it will throw a range error. Try what["something"] = tuple(20, 0); instead.
Jun 20 2018