From: "ara.t.howard" Date: 2007-10-13T11:42:58+09:00 Subject: Re: range max On Oct 12, 2007, at 8:05 PM, Brian Adkins wrote: >> >> 0 ... 1 >> >> we know that max != 0, so > > Wrong. (0...1).max_int -> 0 (see code in other post) you code does not return the max, it returns the 'end', and incorrectly in some cases. any range/interval whose end > start *must* have size > 0. therefore the max cannot == start. i think you are confusing the concept of sequence with that of a range http://en.wikipedia.org/wiki/Sequence # sequence http://en.wikipedia.org/wiki/Interval_%28mathematics%29 # range there is *no* constraint on ruby ranges to be either - one may use the range to represent either. if one uses it to represent an interval the, with an open ended (... vs ..) range there is no way to compute the max. this is a very useful property because you can use it to do things like f = 0.42 r = 0 ... 1 if f > r.start and f < r.end ... so, if we are talking general purpose methods, which the OP was, Range#max cannot be written to be general purpose, even for integer 'ranges' > >> max = 0.9? >> max = 0.99? >> max = 0.999? >> max = 0.9999? > > What the heck are you talking about? Do you really think that 0.9 or > 0.99 is in the range (0...1) ? yes. but it is not in the integer sequence. regards. a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama