From: Glen Holcomb Date: 2008-07-03T01:30:02+09:00 Subject: Re: Ranges and Enumerable problems ------=_Part_2140_23145301.1215016383463 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Jul 2, 2008 at 9:12 AM, Robert Klemme wrote: > 2008/7/2 Glen Holcomb : > > Okay so when I play with "!".."~" wrong things happen. > > > > ("!".."~").include?("W") > > true > > > > ("!.."~").include?(" ") > > false > > > > so far so good, however. > > > > ("!".."~").each do |c| > > puts c > > end > > > > ! > > " > > # > > $ > > % > > & > > ' > > ( > > ) > > * > > + > > , > > - > > . > > / > > 0 > > 1 > > 2 > > 3 > > 4 > > 5 > > 6 > > 7 > > 8 > > 9 > > => "!".."~" > > > > This is wrong! > > > > ("!".."~").last > > => "~" > > > > This is also right. > > > > It looks to me like a problem with the Enumerable mixin but I guess the > > question is why? > > Note this > > irb(main):003:0> "9".succ > => "10" > > Try this instead: > > (?!..?~).each {|c| p c.chr} > > irb(main):008:0> (?!..?~).include? ?\ > => false > > > Kind regards > > robert > > > > -- > use.inject do |as, often| as.you_can - without end > > Thanks Robert, That is interesting. I wonder why it doesn't work as you would expect. The range object seems to be correct (at least through limited include? testing) however it returns incomplete info whenever you use an Enumerable method or a method that appears to use an Enumerable method. -- "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can't hear a word you're saying." -Greg Graffin (Bad Religion) ------=_Part_2140_23145301.1215016383463--