Search code examples
javaeclipsextend

class constructors in Xtend


I'm trying out Xtend. Is it possible to make constructors? It seems so simple, but I'm getting an error when I try something like this:

class Scope extends Rect {

    public Scope(){
        super()
    }

}

Solution

  • Constructors are defined by overloading a new() method:

    class MyClass extends AnotherClass {
      new(String s) {
        super(s)
      }
    
      new() {
        this("default")
      }
    }
    

    look here