Hi,

> I was trying to implement a breadth first search where I would mutate the 
> search queue while iterating through it. Simplified, it was something like 
> this:
>
>        numbers = [1, 2, 3, 4]
>        numbers.each { |number|
>                numbers << (1+number) unless number > 3
>                puts number
>        }

Modifying the object you're iterating on is undefined behavior, even in Ruby:
http://www.ruby-forum.com/topic/188211#821599

It's generally easy to modify your code to either iterate on a copy of
the array or looping with an index (numbers.length.times {...} or i =
0; while i < numbers.length; ..; end depending on what you want to
do).

> Also, is this type of exception one that should be caught by the VM and 
> propagated as a normal Ruby Exception that I could rescue?

It should definitively be propagated as a normal Ruby exception. Could
you file a ticket on trac for that?
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to