[MacRuby-devel] enumerateObjectsUsingBlock

Laurent Sansonetti lsansonetti at apple.com
Wed Jan 12 12:36:07 PST 2011


Hi Alan,

Ouch, you may have found a bug… can you file a ticket? I will look into it for the upcoming release.

Thanks,
Laurent

On Jan 12, 2011, at 1:03 AM, Alan Skipp wrote:

> Hi everyone,
> Below is a reduction of a problem I've noticed when using 'enumerateObjectsUsingBlock' from inside a proc. The line which causes trouble is:
> 	[1,2,3].enumerateObjectsUsingBlock( Proc.new { |o, i, s| puts "inner enumeration #{o}" } )
> 
> If this line is replaced with:
> 	[1,2,3].each { |e| puts "inner enumeration #{e}" }
> Then the code behaves as expected.
> 
> 
> framework 'Foundation'
> 
> proc = Proc.new do |arg|
>   [1,2,3].enumerateObjectsUsingBlock( Proc.new { |o, i, s| puts "inner enumeration #{o}" } )
>   puts arg.upcase
> end
> 
> %w[a b c].enumerateObjectsUsingBlock( Proc.new do |obj, idx, stop|
>   proc.call(obj)
> end
> )
> 
> The output is as follows:
> 
> inner enumeration 1
> inner enumeration 2
> inner enumeration 3
> A
> inner enumeration b
> inner enumeration c
> 
> 
> The output I would expect is this:
> 
> inner enumeration 1
> inner enumeration 2
> inner enumeration 3
> A
> inner enumeration 1
> inner enumeration 2
> inner enumeration 3
> B
> inner enumeration 1
> inner enumeration 2
> inner enumeration 3
> C
> 
> 
> _______________________________________________
> 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/20110112/e390a773/attachment.html>


More information about the MacRuby-devel mailing list