Re: how to assign tuple named Tuple easily

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:15:05 UTC, Adam D. Ruppe wrote: On Monday, 13 March 2017 at 14:09:58 UTC, Inquie wrote: Yeah, so, surely though we can extract the names from the variable and then supply those like I mentioned? Yeah, we prolly could, but a simpler thing might be to just use typ

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Inquie via Digitalmars-d-learn
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

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:09:58 UTC, Inquie wrote: Yeah, so, surely though we can extract the names from the variable and then supply those like I mentioned? Yeah, we prolly could, but a simpler thing might be to just use typeof: Tuple!(int, "A")[] x; x ~= typeof(x[0])(3

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 00:51:27 UTC, Adam D. Ruppe wrote: On Monday, 13 March 2017 at 00:02:12 UTC, Inquie wrote: I just figured it didn't work in general, but seems to be an issue with appending. Oh, it is because of the implicit construction thing, see my answer here to learn more: ht

Re: how to assign tuple named Tuple easily

2017-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 March 2017 at 00:02:12 UTC, Inquie wrote: I just figured it didn't work in general, but seems to be an issue with appending. Oh, it is because of the implicit construction thing, see my answer here to learn more: http://stackoverflow.com/a/42285015/1457000 You can construct th

Re: how to assign tuple named Tuple easily

2017-03-12 Thread ag0aep6g via Digitalmars-d-learn
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);

Re: how to assign tuple named Tuple easily

2017-03-12 Thread Inquie via Digitalmars-d-learn
On Sunday, 12 March 2017 at 23:55:44 UTC, Adam D. Ruppe wrote: On Sunday, 12 March 2017 at 23:16:48 UTC, Inquie wrote: Tuple!(int, "A") x; x = tuple(3); fails of course umm it works for me... Ok, it doesn't work for appending though ;) Tuple!(int, "A", double, "B")[] y; y ~= tuple!("A", "

Re: how to assign tuple named Tuple easily

2017-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 12 March 2017 at 23:16:48 UTC, Inquie wrote: Tuple!(int, "A") x; x = tuple(3); fails of course umm it works for me...

how to assign tuple named Tuple easily

2017-03-12 Thread Inquie via Digitalmars-d-learn
Tuple!(int, "A") x; x = tuple(3); fails of course x = tuple!("A")(3); Works but specifying the name seems to be redundant. Can we simplify for the more complex case? e.g., x = tuple!(GetTypleNames!x)(3); which should then be possible to simplify even further to x = tuple(3); or, rather