custom_load_storeat.gravity 378 B

1234567891011121314151617181920212223242526
  1. #unittest {
  2. name: "Custom load/store";
  3. error: NONE;
  4. result: "bar";
  5. };
  6. class A {
  7. private var storage;
  8. func init() {
  9. storage = [:];
  10. }
  11. func storeat(key, value) {
  12. storage[key] = value;
  13. }
  14. func loadat(key) {
  15. return storage[key];
  16. }
  17. }
  18. func main() {
  19. var inst = A();
  20. inst["foo"] = "bar";
  21. return inst["foo"];
  22. }