[Rubycocoa-devel 1238] NSString duck typing via method_missing

Back to archive index

Satoshi Nakagawa snaka****@infot*****
Wed Nov 14 01:34:02 JST 2007


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




More information about the Rubycocoa-devel mailing list
Back to archive index