Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 0.23 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;;;;;; GLOBAL THIS
  2.  
  3. (defn f []
  4.   (this-as self
  5.     (println self))
  6.   [self])
  7.  
  8. (f)
  9. ;; #<Object Global>
  10. ;;=> [#<undefined>]
  11.  
  12. ;;;;;; METHOD THIS
  13.  
  14. (def o (array))
  15.  
  16. (extend-object! o {:foo f})
  17.  
  18. (. o (foo))
  19. ;; #<Array []>
  20. ;;=> [#<undefined>]