Sciter 2.0.2.0 is out with new TIScript features

One of such features added in 2.0.2.0 is support of member variables declarations in classes.

By using this var name = value construction you can define member (instance) variables:

This code:

class Foo {
  this var one = 1, // member variable
           two = 2; // member variable

  function sum() { return this.one + this.two; }
}

var foo = new Foo();
stdout << foo.sum() << "\n";

will output ‘3’ even there is no constructor is defined in the class.
Each instance of the class is born with those this.one and this.two variables having their initial values.

If there is other class that inherits such Foo class then it gets member variables declared in its super class as the ones declared in the class iself.

This code:

class Bar: Foo {
  this var three = 3; // member variable

  function sum() { return this.three + super.sum(); }
}

var bar = new Bar();
stdout << bar.sum() << "\n";

will ouput ‘6’ as the bar instance contains this.one, this.two and this.three variables.

1 Reply to “Sciter 2.0.2.0 is out with new TIScript features”

Comments are closed.