Random D geekout
Arne
arne at linux.nu
Fri Apr 20 11:50:16 PDT 2012
On Friday, 20 April 2012 at 11:23:49 UTC, Steven Schveighoffer
wrote:
> On Fri, 20 Apr 2012 00:06:41 -0400, H. S. Teoh
> <hsteoh at quickfur.ath.cx> wrote:
>
>
>> The only complaint is that I couldn't write auto[string] dgs
>> and have
>> the compiler auto-infer the delegate type. :-)
>
> Does this not work?
>
> auto dgs = ...
>
> Also, it doesn't look like that needs to be in the inner loop.
> Each time you specify an AA literal, it allocates a new one.
> So you are allocating another AA literal per line.
>
> -Steve
auto dgs =
[
"name": (string value) {d.name = value; },
"phone": (string value) => cast(void)(d.phone = value),
"age": (string value) => cast(void)(d.age = value.to!int()),
];
This works... is there a better way, to avoid cast?
More information about the Digitalmars-d
mailing list