From: Michael Fellinger Date: 2010-06-19T16:04:51+09:00 Subject: Re: String comparison. Why does Ruby consider this true? On Sat, Jun 19, 2010 at 6:21 AM, Josh Cheek wrote: > > Thanks, but it doesn't seem to work on 1.8 > > > RUBY_VERSION # => "1.8.7" > > %w[Xeo xeo ball ABC abc].sort.each{|word| p word => word.codepoints.to_a } # > => > # ~> -:3: undefined method `codepoints' for "ABC":String (NoMethodError) > # ~>     from -:3:in `each' > # ~>     from -:3 > > > > > And the 1.8 ways to get it don't work on 1.9 (ie "a"[0]) >> %w[Xeo xeo ball ABC abc].sort.each{|word| p word => word.unpack('C*') } {"ABC"=>[65, 66, 67]} {"Xeo"=>[88, 101, 111]} {"abc"=>[97, 98, 99]} {"ball"=>[98, 97, 108, 108]} {"xeo"=>[120, 101, 111]} => ["ABC", "Xeo", "abc", "ball", "xeo"] There is always a way to make things work on both, it's just that I don't care much about 1.8 anymore. -- Michael Fellinger CTO, The Rubyists, LLC