A different tuple syntax

Frank Fuente a at b.com
Thu May 30 05:36:40 PDT 2013


On Thursday, 30 May 2013 at 12:32:46 UTC, bearophile wrote:
> If you don't like to introduce a new keyword, then a different 
> alternative is to use the @ again, a bit like UDAs:
>
> @{...}
>
> @[10] @{int, string} tup = @{1, "hi"}; // With UDA.
> foreach (Float; @{float, double, real}) { ... }
> auto @{x, y} = @{1, "hi"};
> @{auto x, y} = @{1, "hi"};
> @{int x, string y} = @{1, "hi"};
> foreach (i, const @{x, y}; [@{1,2}, @{3,4}, @{5,6}, ...]) {
> void foo(@{int, string name}, string msg);
> (@{A a, B b}) => a + b;
> switch (tup) { case @{1, 2}: ... }
>
> Bye,
> bearophile

My eyes, they burn...


More information about the Digitalmars-d mailing list