digitalmars.D - "Class.this" equivalent ?
- Dan (9/9) Jan 02 2007 All,
- Alexander Panek (18/29) Jan 02 2007 You can use the *outer* keyword to access the class wrapping a nested cl...
- Dan (3/32) Jan 02 2007 Thanks.
All,
How can I access a reference to an enclosing class in D? ... something similar
to the following Java code:
class A {
class B {
A ref;
B() { ref = A.this; }
}
}
Jan 02 2007
Dan wrote:
All,
How can I access a reference to an enclosing class in D? ... something similar
to the following Java code:
class A {
class B {
A ref;
B() { ref = A.this; }
}
}
You can use the *outer* keyword to access the class wrapping a nested class.
Like:
class Outer
{
class Inner
{
Outer foo()
{
return this.outer;
}
}
void bar()
{
Inner i = new Inner;
assert(this == i.foo());
}
}
Jan 02 2007
== Quote from Alexander Panek (a.panek brainsware.org)'s articleDan wrote:Thanks. --DanAll, How can I access a reference to an enclosing class in D? ... something similar to the following Java code: class A { class B { A ref; B() { ref = A.this; } } }You can use the *outer* keyword to access the class wrapping a nested class. Like: class Outer { class Inner { Outer foo() { return this.outer; } } void bar() { Inner i = new Inner; assert(this == i.foo()); } }
Jan 02 2007








Dan <ddaglas gmail.com>