Delayed const variable initialization
Jesse Phillips via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 13 10:18:51 PDT 2015
On Monday, 13 July 2015 at 14:41:36 UTC, Steven Schveighoffer
wrote:
> You can also do a temporary lambda that you call immediately,
> but I'm not 100% sure of the syntax. Someone will chime in with
> the answer :)
>
> -Steve
Syntax is easy:
void main() {
bool condition;
const x = {
if(condition) {
return 1;
} else {
return 2;
}
}();
}
More information about the Digitalmars-d-learn
mailing list