class Foo { int baz = 2; }
void main() { import std.stdio : writeln; Foo foo; { Foo bar = new Foo(); foo = bar; } //bar is now out of scope assert(foo.baz == 2); }
jmh530 via Digitalmars-d-learn Sun, 12 Jun 2016 11:26:25 -0700
class Foo { int baz = 2; }
void main() { import std.stdio : writeln; Foo foo; { Foo bar = new Foo(); foo = bar; } //bar is now out of scope assert(foo.baz == 2); }