On 1/20/06, Markus Tarmak <m4rkusha / gmail.com> wrote:
> Adam Shelly wrote:
> > That part I know.  But I expected (1...x) to be exactly equivalent to
> > (1..x-1)
>
> It's not equivalent because you forgot about floating point numbers.
>
> irb(main):001:0> (1...9).include? 8.9
> => true

Exactly. Think of a..b in ruby as equivalent[1] to [a, b] in
mathematics, and a...b as equivalent to [a, b). The latter will
include (b - delta) for all delta > 0 and < (b - a), no matter how
small. The only difference between [a, b] and [a, b) is the *one*
value b. In set terminology: [a, b] - [a, b) = { b } and |[a, b] - [a,
b)| = 1.

Jacob Fugal

[1] This equivalence/analogy only holds for well ordered Range objects
such as those on Numeric. Don't expect this to make any sense for
non-Numeric ranges. I never use ... with non-numeric ranges anyways.