非staticな関数はselfを参照できる?
selfが参照できるんですねぇ〜。
関数ってもっと潔癖なものと思っていたんだけど。うーむ。
-- 非staticな関数はselfを参照できる。 -- selfを介してどこまでできるのか? class TestFunction instance variables private a: int := 5; operations public getValue: () ==> int getValue() == return a; public setValue: int ==> int setValue(newValue) == ( a := newValue; return a ); functions public test1: () -> int test1() == self.a; -- 関数でもselfを介してインスタンス変数の参照が可能 public test2: () -> int test2() == self.getValue(); -- 関数でもselfを介して操作が可能 public test3: () -> int test3() == self.setValue(99); -- 関数でも破壊的操作が可能 end TestFunction