Created
October 12, 2012 20:32
-
-
Save jstorimer/3881340 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Foo | |
include Module.new { | |
def this_works | |
end | |
} | |
include Module.new do | |
def this_doesnt_work | |
end | |
end | |
end | |
foo = Foo.new | |
foo.this_works | |
foo.this_doesnt_work | |
It's failing because the block precedence is being applied wrongly in the first. The block is being consumed by include in one case and Module.new in the other.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The second example is parsed like this:
That is, the block is an argument to
include
, not toModule.new
.