From: Tom Cloyd Date: 2009-05-13T09:04:49+09:00 Subject: Re: Whaaaaat? Kirk Haines wrote: > On Tue, May 12, 2009 at 5:39 PM, Tom Cloyd wrote: > >> p [0..5].include? 0 >> false >> p [0..5].member? 0 >> false >> >> This is nuts. The world is flat, evidently. >> >> Can someone explain this nonsense? >> > > [0..5] is an array with a single element, a Range object representing > the range from 0 to 5. > > (0..5).to_a gives you [0,1,2,3,4,5] which is probably what you assumed > you got with [0..5] > > (0..5).include?(0) will work, as well, because ranges support the > include? method. > > > Kirk Haines > > > Thanks, Kirk. That's the best answer yet. Very helpful. t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~