Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. # File: methods-2.rb
  2. #
  3. def double(a)
  4. puts "I am block #1 and I will double my argument: #{a * 2}"
  5. end
  6.  
  7. def triple(a)
  8. puts "I am block #2 and I will triple my argument: #{a * 3}"
  9. end
  10.  
  11. def foo(b1, b2, number)
  12. b1.call(number)
  13. b2.call(number)
  14. end
  15.  
  16. puts 'I will now call foo'
  17.  
  18. foo(method(:double), method(:triple), 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement