Yep, Chad Fowler explained to me that it's the difference between precedence
and binding with do/end vs {}

- Matt

On Sun, Jan 9, 2011 at 5:57 PM, Vincent Isambart <vincent.isamb...@gmail.com
> wrote:

> > 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)
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to