Created
January 10, 2012 03:15
-
-
Save bitops/1586656 to your computer and use it in GitHub Desktop.
optional params and blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(x, y=nil, &block) | |
puts x | |
puts y | |
block.call | |
end | |
f(1) { puts "inside block" } | |
f(1, 2) { puts "inside block" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment