[MacRuby] #1113: unexpected behaviour with enumerateObjectsUsingBlock
MacRuby
ruby-noreply at macosforge.org
Wed Jan 12 14:51:54 PST 2011
#1113: unexpected behaviour with enumerateObjectsUsingBlock
----------------------------------+-----------------------------------------
Reporter: al_skipp@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
If a Proc is defined that uses 'enumerateObjectsUsingBlock' and that proc
is then called on all items of an array by iterating through the array
with 'enumerateObjectsUsingBlock', the parameters to both blocks are sent
to the inner enumeration. Example below.
{{{
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
)
}}}
Output:
{{{
inner enumeration 1
inner enumeration 2
inner enumeration 3
A
inner enumeration b
inner enumeration c
}}}
Expected output:
{{{
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
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/1113>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list