Hey,
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
}
This works fine for arrays that are being made in the MacRuby VM, but if I get
an array back from an Objective-C method and try to iterate over that array
then I would get an exception (which segfaulted the VM) when I tried to mutate
the array during iteration. Simplified, it would be something like this:
numbers = NSMutableArray.alloc.init
numbers.addObjectsFromArray [1, 2, 3, 4]
numbers.each { |number|
numbers << (1+number) unless number > 3
puts number
}
Should both types of arrays work the same way? An instance of NSMutableArray
says its class is Array, so I thought that they would.
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?
Mark Rada
[email protected]
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel