From: "Martin J. Dürst" Date: 2013-11-12T10:04:26+09:00 Subject: [ruby-core:58285] Re: [ruby-trunk - Feature #6727] Add Array#rest (with implementation) On 2013/11/12 2:29, fuadksd (Fuad Saud) wrote: > > Issue #6727 has been updated by fuadksd (Fuad Saud). > > > Reading back the comments, I realize Indexable may be a good idea for String/Array polymorphism. The idea is already there. If you check, you'll notice that whenever something makes sense both for an Array and a String (e.g. #length), it's the same method with the same arguments. There is no explicit Indexable module or superclass because for efficiency, implementations are separate (and sharing implementations would be the main/only reason for using a module or a superclass in Ruby). But there is also some aspect in which the two classes don't match. For Array, #each iterates over elements. But for String, #each doesn't exist. For the discussion in this issue, String#each would have to iterate over characters, but in Ruby 1.8, it iterated over lines, and that's why it was removed altogether from Ruby 1.9, and we have #each_char, #each_byte, #each_line now. Regards, Martin.