Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()
    }

}
like image 981
brendanzab Avatar asked Nov 07 '11 08:11

brendanzab


2 Answers

Constructors are defined by overloading a new() method:

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

  new() {
    this("default")
  }
}

look here

like image 80
Lev Avatar answered Oct 09 '22 09:10

Lev


The next release of Xtend is planned for mid December. It'll have support for declaring constructors.

See http://www.eclipse.org/Xtext/xtend/#whatsnext

like image 42
Sven Efftinge Avatar answered Oct 09 '22 07:10

Sven Efftinge