[MacRuby-devel] Array and NSMutableArray mutability

Caio Chassot lists at caiochassot.com
Sun Jan 30 21:37:46 PST 2011


On 2011-01-30, at 23:55 , Mark Rada wrote:
> 
> Should both types of arrays work the same way? An instance of NSMutableArray says its class is Array, so I thought that they would.

There's something weird going on in there, I don't really know the details of it, but:

A while back I had issues calling #count(foo) on a NSMutableArray, even though it #is_a?Array, because it tried to call ObjC's count, which doesn't take an optional argument.

Whenever I need ruby semantics on an array returned from a Cocoa framework, I use Array.new(my_ns_array).


Clearly your case is a bit worse than mine. I don't believe it should segfault.


Anyway, I can see this Array/NSArray incomplete equivalence being a source of endless confusion. I'm curious what tradeoffs are at play here.


More information about the MacRuby-devel mailing list