From: Dave Thomas Date: 2002-02-13T03:09:58+09:00 Subject: Re: [newbie] make first letter lowercase matz@ruby-lang.org (Yukihiro Matsumoto) writes: > |It isn't very orthogonal. > > I guess I understand what you mean, but could you tell me how it's not > orthogonal just to clarify? Sorry - I was feeling minimalist this morning :) It seems to me that the intent here is expose some part of a string as a String it its own right, allow operations on that string, and then have those operations affect the original. One way of doing that would be to have every single string mutator to accept start and end positions (in fact to be consistent they should also accept a range, a regexp, and a string). So we'd have str.upcase!(2,4) str.tr!('a', 'b', 5, 6) and so on. This seems bad: we have a single concept, the exposed substring, and put its implementation into many different methods. So, perhaps a better way might be to make the concept of exposing a substring for manipulation orthogonal to that manipulation. Something like: str.expose!(1,2).upcase str.expose!(5,6).tr('a', 'b') We could then make it more generic: ary.expose(2,-2)!.sort # sort all bug first and last elements In general, this could probably be done as a mixin on all classes that implement slices. Dave