From: James Coglan Date: 2009-08-18T22:30:32+09:00 Subject: Re: Bizarre Range behavior --001517448064a725cf04716a854e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/8/18 James Coglan > > > 2009/8/18 Yukihiro Matsumoto > > Hi, >> >> In message "Re: Bizarre Range behavior" >> on Tue, 18 Aug 2009 21:31:38 +0900, Daniel DeLorme >> writes: >> >> |That sounds nice and consistent, but why limit ourselves to numbers? >> | ("y".."aa").to_a >> |should then generate ["y", "z", "aa"] since that's what String#succ >> |generates. Sounds like this could snowball into a nightmare of >> |incompatible changes. >> >> Indeed. The issue is that it's not easily distinguishable whether >> a sequence using #succ from a string reaches to another, or not. >> If there's affordable scheme to implement, I'd love to check in. > > > For user-defined objects, the `<=>` method is used to determine whether the > end of a range has been reached or exceeded, and it seems like 1.8 does this > for strings (and numbers, of course). I prefer 1.8's consistent application > of this rule. > Actually I need to qualify this: the rule seems to be that if `(a <=> b) == 1` and `a.length >= b.length` then b is not reachable using a `succ` sequence from a. -- James Coglan http://jcoglan.com --001517448064a725cf04716a854e--