[MacRuby-devel] NSArray's count and Ruby Array#count
Caio Chassot
lists at caiochassot.com
Tue Oct 5 15:27:11 PDT 2010
On 2010-10-05, at 18:15 , Laurent Sansonetti wrote:
>
> You found out an exception :) As you know, NSArray responds to -count which simply return the number of elements it contains. But Ruby Array defines #count which has different semantics.
>
> To not conflict with NSArray, the Ruby #count is only defined on Ruby arrays.
Yeah. But it appears to me ruby's count is just a superset of NSArray -count, they're not really incompatible. Now, maybe I'm overlooking something. But I think this could be made to work.
So I was just wondering if I should file a bug or if this works as expected.
> However, I do not understand where #count is used in your snippet. Is it used in Pathname?
Oh, sorry about the confusion. I just posted that an an example to show that after performing a few ruby method calls that return new arrays (map, compact) on an NSArray, I'd expect to have a Ruby array.
The entire script where I got that from is here:
http://github.com/kch/mac-user-scripts/blob/master/Applications/Finder/Paste%20as%20Symlink.rb
You can see the count call later in the code.
More information about the MacRuby-devel
mailing list