From: Austin Ziegler Date: 2004-08-12T22:19:59+09:00 Subject: Re: Bug in Range#end with exclusive ranges? On Thu, 12 Aug 2004 16:01:11 +0900, Martin DeMello wrote: > Austin Ziegler wrote: >> In mathematical range notation, the difference between 0..50 and 0...50 is >> [0, 50] and [0, 50). Thus: > > It doesn't seem quite right that Ruby should do this though > irb(main):001:0> a = (0..50) > a = (0..50) > => 0..50 > irb(main):002:0> b = (0.0..50.0) > b = (0.0..50.0) > => 0.0..50.0 > irb(main):004:0> a.last > a.last > => 50 > irb(main):005:0> a.last.class > a.last.class > => Fixnum > irb(main):006:0> b.last.class > b.last.class > => Float > irb(main):007:0> a.include?(49.9) > a.include?(49.9) > => true > irb(main):008:0> b.include?(49.9) > b.include?(49.9) > => true > > Shouldn't Range#include work differently for integers? No. You want Range#member? ----------------------------------------------------- Range#member? rng.member?(val) => true or false ------------------------------------------------------------------- Return +true+ if _val_ is one of the values in _rng_ (that is if +Range#each+ would return _val_ at some point). -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca