Created
May 24, 2012 20:44
-
-
Save jgaskins/2784127 to your computer and use it in GitHub Desktop.
Blocks are, indeed, represented as Proc objects
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 m &block | |
block | |
end | |
def n &block | |
block.call | |
end | |
p n(&m { 'This is my block' }) | |
# => "This is my block" | |
p n &(Proc.new { 'This is another block' }) | |
# => "This is another block" | |
p m { 'Another block' }.class | |
# => Proc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment