Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. actor Main
  2. new create(env: Env) =>
  3. let fox = recover Fox(env) end
  4. let wolf = Wolf(env, consume fox)
  5. wolf()
  6. wolf()
  7.  
  8. class Wolf
  9. let _env: Env
  10. let fox: Fox ref
  11.  
  12. new create(env: Env, fox': Fox iso) =>
  13. _env = env
  14. fox = consume fox'
  15.  
  16. // v-- inserting a "ref" here fixes the issue
  17. fun ref apply() =>
  18. _env.out.print("Wolf: I'm in a ref function! 🐺")
  19. fox()
  20.  
  21. class Fox
  22. let _env: Env
  23. var _x: U32 = 0
  24.  
  25. new create(env: Env) =>
  26. _env = env
  27.  
  28. fun ref apply() =>
  29. _x = _x + 1
  30. _env.out.print("Fox: I'm in a ref function, and look at my number: " + _x.string() + " 🦊")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement