From: Joel VanderWerf Date: 2005-11-23T17:18:10+09:00 Subject: Re: [BUG] string range membership Brian Schr�der wrote: > I'd argue that it is not a bug, as there is no unique isomorphie from > strings to integers. Some well known functions would be hex, octal and > decimal encoding. I.e. '2' ... '10' could be understood as 2 ... 8, or > 2 ... 16 or 2 ... 10 or error ... 2 depending on the base. > > Only you can now what the string means, so convert it to an integer > and do the range test on integers. I was going to make that argument, but I realized that #each (by way of #succ) *does* have some extra knowledge (or assumptions) about strings, and it's pretty smart: irb(main):003:0> ('1.1'..'10.1').each {|s| p s} "1.1" "1.2" "1.3" "1.4" ... ... "9.6" "9.7" "9.8" "9.9" "10.0" "10.1" => "1.1".."10.1" irb(main):004:0> ('1.6.4'..'1.8.3').each {|s| p s} "1.6.4" "1.6.5" "1.6.6" "1.6.7" "1.6.8" "1.6.9" "1.7.0" "1.7.1" "1.7.2" "1.7.3" "1.7.4" "1.7.5" "1.7.6" "1.7.7" "1.7.8" "1.7.9" "1.8.0" "1.8.1" "1.8.2" "1.8.3" => "1.6.4".."1.8.3" I guess it is just impractical for Range#member? to test using #succ. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407