[Rubycocoa-devel 884] Re: NSString duck typing as Ruby String

アーカイブの一覧に戻る

Laurent Sansonetti lsans****@apple*****
Mon May 21 23:38:59 JST 2007


Hi Kimura-san,

This is great work. I think that we should also apply the same  
#method_missing logic to NSArray and NSDictionary. Right now these  
modules mix Enumerable but Array and Hash respond to more methods than  
Enumerable.

Laurent

On May 21, 2007, at 4:05 PM, kimura wataru wrote:

> Hi,
>
> RubyCocoa codes have many "to_s". I wrote a patch to let NSString
> (and its subclasses) to behave as Ruby String. This patch enables to
> reduce "to_s" from RubyCocoa codes.
>
> I commited this patch as r1755.
>
> (1) enable to compare between NSString and String without to_s
>      rbstr == nsstr
>      nsstr != rbstr
> (2) enable to invoke String methods (e.g. gsub) for NSString
>      nsstr.gsub(...)
>      nsstr + "other string"
>
> Cocoa has immutable string, different form Ruby. If bang method
> (like gsub!, <<) is invoked for immutable string, an Exception
> will occur.
>
> -- 
> kimura wataru
> <nsstr_ducktype.patch>_______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




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