Guest User

Wut

a guest
Apr 23rd, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.35 KB | None | 0 0
  1. type
  2.   CoinRef = ref RootObj
  3.   PenRef  = ref RootObj
  4.  
  5. method update(o: RootObj) = discard
  6. method update(p: PenRef)  = echo "Im a pen"
  7. method update(c: CoinRef) = echo "Im a coin"
  8.  
  9. let s: seq[ref RootObj]   = @[CoinRef(), PenRef(), CoinRef(), PenRef()]
  10.  
  11. for i in s: update i
  12.  
  13. # Result:
  14. # >Im a pen
  15. # >Im a pen
  16. # >Im a pen
  17. # >Im a pen
Advertisement
Add Comment
Please, Sign In to add comment