From: "Steve [RubyTalk]" Date: 2005-12-02T05:33:19+09:00 Subject: Re: String + Range = Strange Bob Showalter wrote: > The point is that even though "aa".."b1" is a valid range, calling > succ repeatedly from the starting point will never yield the endpoint. This, I think is the crux of the matter. It seems to me that given that if "aa".."b1" is a valid range, that calling calling succ on "aa" should logically eventually reach "b1". I understand that in Ruby, today, it doesn't. I suppose I can get the behaviour I expect by doing something like this. class String def succ s=String.new self (s.length-1).downto 0 do |i| s[i]=(s[i]+1)&0xff return s unless s[i]==0 end 1.chr.concat s end end Is there any good reason that this isn't the default behaviour for succ - given that Ruby claims an objective is to have "sensible defaults"? I can see a justification for having a method defined how String#succ is defined today - but I don't see why it has to be as the default succ method... especially since it gives such counter-intuitive results when used with ranges. Alternatively - I suppose - it might make sense if ranges didn't use succ? Ranges in regexps don't work the same "smart" way - wouldn't consistent default behaviour be far preferable?