[Rubycocoa-devel 1239] Re: NSString duck typing via method_missing

アーカイブの一覧に戻る

Eloy Duran eloy.****@gmail*****
Wed Nov 14 01:35:02 JST 2007


I agree, we should remove it.

Eloy

On 13 nov 2007, at 17:34, Satoshi Nakagawa wrote:

> Hi,
>
> I suggest that we should remove NSStirng#method_missing.
>
> Because an index number for NSString is character based, while one for
> Ruby String is byte based.
>
> I ported many Ruby String methods to NSString, and these are character
> based.  So now NSString have both character based methods and byte
> based methods.
>
> For example, scan method.
>
> I haven't ported the scan method.  So when I call NSString#scan, it
> causes a method_missing call and it would be passed to String#scan.
>
> Therefore,
>
> "あいうえお".to_ns.scan(/い/) {|a| puts $~.begin(0) }
> # => 3 (should be 1)
>
> I got 3 in result.  But it should be 1 if NSString uses character
> based indexes.  It's confusing.  I want to make NSString methods
> confirmed to be character based.
>
> What do you think?
>
> --
> Satoshi Nakagawa
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
アーカイブの一覧に戻る