Does D have too many features?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat Apr 28 18:47:22 PDT 2012
On 4/29/12, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> struct S
> {
> int field1;
> float field2;
> string field3;
> }
> then you can do
>
> auto s = S(5, 7.2, "hello");
>
> The ability to do
>
> S s = {5, 7.2, "hello"};
>
> gains you _nothing_.
That's not really the benefit of those initializers. This is:
S[] arr = [{field2 = 1.0}, {field2 = 0.5}];
It's a real benefit when unittesting because it allows me to quickly
create variables with some interesting state which I can then test.
More information about the Digitalmars-d
mailing list