Go, D, and the GC
Kagamin via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 5 09:25:26 PDT 2015
On Monday, 5 October 2015 at 11:41:11 UTC, Marc Schütz wrote:
> `@disable this();` works fine to prevent the user from doing
> that accidentally. But in your example, this doesn't happen by
> accident; you explicitly told the compiler to use the .init
> value. That's not something you do just because you can, you
> need to have a reason for it. Presumably a user doing this
> would know what they're doing.
Do it by accident:
T safeFront(T[] r)
{
if(r.length==0)return T.init;
return r[0];
}
More information about the Digitalmars-d
mailing list