Created
January 25, 2012 07:55
-
-
Save ggilder/1675279 to your computer and use it in GitHub Desktop.
MacRuby bug with #method.call 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
class Foo | |
def bar | |
if block_given? | |
yield | |
else | |
puts "Foo#bar: please give me a block :(" | |
end | |
end | |
end | |
Foo.new.method(:bar).call() { puts "in the block 1" } | |
Foo.new.method(:bar).call( &Proc.new { puts "in the block 2" } ) | |
=begin | |
Running the above code under MRI and MacRuby | |
→ ruby blocks.rb | |
in the block 1 | |
in the block 2 | |
→ macruby blocks.rb | |
Foo#bar: please give me a block :( | |
Foo#bar: please give me a block :( | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment