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

Matt Aimonetti mattaimonetti at gmail.com
Sun Jan 9 18:39:03 PST 2011


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.isambart at 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 at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110109/f5954435/attachment.html>


More information about the MacRuby-devel mailing list