From: Eric Hodel Date: 2005-07-01T18:13:33+09:00 Subject: String vs Array [Was: shift vs. slice!(0) and others] On 30 Jun 2005, at 21:57, Daniel Brockman wrote: > Eric Hodel writes: > >>> OT... does anybody else hate it that the String and Array API's >>> have suttle differences and lack methods of the other? > >> No, I don't notice it at all. Strings aren't Arrays and Arrays >> aren't Strings. They only look the same if you squint really hard. > > Which is exactly what Jason was complaining about. > You *shouldn't* have to squint to make them look alike. I have never needed them to look alike much beyond << and empty?. The differences between the two are what I appreciate about the differences. I want String to be good at being a String, and Array to be good at being a collection. Interface unity takes back seat. (If I have to work with individual characters, split '' has been more than adequate.) How have you needed them to look alike? In any event, the gap is hardly insurmountable: class String def shift return nil if empty? chr = self[0].chr replace self[1..-1] return chr end end -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04