Method

メソッドです。

method(){}式により生成されます。

主にclass(){}式中で使われ、呼び出し時のthisは呼び出し元のthisが継承されます。また、クラスの中で定義する際にはmethodの表記を省略することができます。

Example

// 別にクラスの外でも定義できる
method outer_method(x){
    x.p;
    this.p;
    this.class.p;
}
 
class Foo{
    _x : 0;
 
    set_x(x){
        _x = x;
    }
    method call_wrap1(m, x){
        m(x);
    }
}
 
foo : Foo();
foo.set_x(10);
 
outer_method("nanchara");
foo.call_wrap1(outer_method, 20);