bind_func.gravity 243 B

1234567891011121314151617181920
  1. #unittest {
  2. name: "Bind function to an existing class.";
  3. error: NONE;
  4. result: 100;
  5. };
  6. class Foo {
  7. var x = 100;
  8. }
  9. func test() {
  10. return self.x;
  11. }
  12. func main() {
  13. var foo = Foo();
  14. foo.bind("test", test);
  15. return foo.test();
  16. }