From: Stefano Crocco Date: 2009-01-08T01:14:00+09:00 Subject: Re: Puzzling behaviour with range... Alle Wednesday 07 January 2009, Raphael Clancy ha scritto: > Hi all! > > I've been over (some of) the documentation, and I can't figure this one > out, can anyone tell me what range is expecting? And, why it's behavior > is different from other numerics? > > $ ruby -v > ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux] > $ irb > irb(main):001:0> 1.class > => Fixnum > irb(main):002:0> 3.14.class > => Float > irb(main):003:0> 1..4.class > ArgumentError: bad value for range > from (irb):3 > from :0 > irb(main):004:0> (1..4).class > => Range > irb(main):005:0> > > Thanks! The point is that 1..4.class is parsed as 1..(4.class), that is 1..Fixnum which, of course, isn't a valid range. Stefano