Guest User

Untitled

a guest
Nov 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # operators.io
  2. OperatorTable addAssignOperator("->", "setLambda")
  3.  
  4. # code.io
  5. Object setLambda := method(
  6. slot_name := call message arguments at(0) name asMutable replaceSeq("\"","")
  7. block_body := call message arguments at(1)
  8. object := call target
  9.  
  10. object setSlot(slot_name, block(
  11. block_body doInContext(object)
  12. ) call)
  13. )
  14.  
  15. # old:
  16. man := Object clone
  17. man name := "Andrey"
  18. man getName := method(name println)
  19. man getName # => "Andrey"
  20.  
  21. # new syntax:
  22. man := Object clone
  23. man name -> "Vorobey"
  24. man getName -> name println
  25. man getName # => "Vorobey"
Add Comment
Please, Sign In to add comment