Guest User

Untitled

a guest
Apr 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. def a(meth)
  2. meth.call(5)
  3. end
  4.  
  5. def b(x)
  6. x+3
  7. end
  8.  
  9. a(method(:b)) #=> 8
  10.  
  11.  
  12. def c(sym)
  13. send(sym,5)
  14. end
  15.  
  16. c(:b) #=> 8
  17.  
  18.  
  19. def d(prok)
  20. prok.call(5)
  21. end
  22.  
  23. d(proc {|x| b(x)}) #=> 8
  24.  
  25. def e
  26. yield 5
  27. end
  28.  
  29. e {|x| b(x)} #=> 8
Add Comment
Please, Sign In to add comment