using tuple as value type for associative array
Flaze07
christianseiji.cs at gmail.com
Thu Jun 21 03:07:14 UTC 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:
>> 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.
huh, interesting, thanks
More information about the Digitalmars-d-learn
mailing list