From: brabuhr@... Date: 2009-08-20T11:53:25+09:00 Subject: Re: Bizarre Range behavior On Wed, Aug 19, 2009 at 10:27 PM, Daniel DeLorme wrote: > Yukihiro Matsumoto wrote: >> 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. > > While investigating this I came across: >>> "\0019".succ > => "\00110" > > I expected the result to be "\0020"; is that a bug? I don't think so, the octal escape is 'eating' the "1" and leaving "9" to succ to "10": $ ruby -v -e 'p "\0019".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\00110" $ ruby -v -e 'p "\019".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\00110" $ ruby -v -e 'p "\19".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\00110" $ ruby -v -e 'p "\1".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\002" $ ruby -v -e 'p "\119".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\t10" $ ruby -v -e 'p "\0119".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\t10" $ ruby -v -e 'p "\00119".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\00120" $ ruby -v -e "p '\0019'.succ" ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\\0020" $ ruby -v -e "p '\00 19'.succ" ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\\00 20" $ ruby -v -e 'p "\01 19".succ' ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] "\001 20"