import std.stdio; class Foo { int a; int opApply(scope int delegate(ref int) dg)const { auto r = dg(a); if (r) return r; return 0; } } class Bar { Foo foo; this(){ foo = new Foo; } void hoge() const { writeln(foo.a); foreach(ref fuga; foo){ fuga = 1; } writeln(foo.a); } } void main() { (new Bar()).hoge(); }