From: "David A. Black" Date: 2010-05-17T23:53:50+09:00 Subject: Re: Range on strings. On Mon, 17 May 2010, Rick DeNatale wrote: > On Mon, May 17, 2010 at 8:29 AM, David A. Black wrote: >> Hi -- >> >> On Fri, 14 May 2010, Vikrant Chaudhary wrote: >> >>> Hi, >>> If I do - >>> >>> ('A'..'Z').include?('AA') >>> >>> It returns "true", while >>> >>> ('A'..'Z').to_a.include?('AA') >>> >>> (of course) returns "false". Is it intentional or possibly a bug? >>> I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on >>> Ubuntu 10.04 x64 >> >> As per the other answers, it's because ('A'..'Z').to_a is an array of >> discrete values, whereas ('A'..'Z') is a range with a start and end. >> I'll just add that in Ruby 1.9, things have changed so that include? >> on a range is, I think, the same as .to_a.include? > > Not exactly. Range#include? for Ruby 1.9 has a few special cases. [snip] Thanks. I was being lazy, so I'm glad for the further info :-) David -- David A. Black, Senior Developer, Cyrus Innovation Inc. THE Ruby training with Black/Brown/McAnally COMPLEAT Coming to Chicago area, June 18-19, 2010! RUBYIST http://www.compleatrubyist.com