how to assign tuple named Tuple easily

Inquie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 13 07:31:30 PDT 2017


On Monday, 13 March 2017 at 00:23:36 UTC, ag0aep6g wrote:
> On 03/13/2017 01:02 AM, Inquie wrote:
>> Ok, it doesn't work for appending though ;)
> [...]
>> Tuple!(int, "A", double, "B")[] y;
>> y ~= tuple(3, 2.5);
>
> Interestingly, this works:
>
>     Tuple!(int, "A", double, "B")[] y;
>     y.length += 1;
>     y[$ - 1] = tuple(3, 2.5);

yeah, seems more like a bug/feature issue. If the compiler can 
figure it out with assignment, it should also be able to figure 
it out with appending EXACTLY because what you wrote. Since a 
default append is effectively the code you wrote above there 
should be no difference between the two. In fact, I would have 
hoped that appending built in arrays would have been expanded 
using the pattern you specifically implemented which should then 
not produce the error and simplify life.






More information about the Digitalmars-d-learn mailing list