[MacRuby-devel] C-level blocks (issue #712)?

Vincent Isambart vincent.isambart at gmail.com
Sun Jan 9 17:57:53 PST 2011


> You are right, still a gotcha tho:
>
> Ruby 1.9.2:
>
>   def foo(a, b={})
>     b[:handler].call if b.has_key?(:handler)
>   end
>   foo :bar, handler: Proc.new do
>     puts 42
>   end
>
> `new': tried to create Proc object without a block (ArgumentError)

Works if you add parentheses though :
  def foo(a, b={})
    b[:handler].call if b.has_key?(:handler)
  end
  foo :bar, handler: (Proc.new do
    puts 42
  end)


More information about the MacRuby-devel mailing list