Skip to content

Instantly share code, notes, and snippets.

@ggilder
Created January 25, 2012 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggilder/1675279 to your computer and use it in GitHub Desktop.
Save ggilder/1675279 to your computer and use it in GitHub Desktop.
MacRuby bug with #method.call and blocks
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