Planet JFX
Advertisement

While instantiating an object with JavaFX's object literal notation, you can declare a "this" variable with a var: statement:

class Parent {
    attribute child: Child;
}

class Child {
    attribute parent: Parent;
}

var aParent = Parent {
    var: myself   // refers to the aParent reference 
                  // (which isn't available for use in the next block)
    child: Child {
        parent: myself
    }
}
println("equal? {aParent == aParent.child.parent}");
Advertisement