In article <1045093515.872338.8431.nullmailer / picachu.netlab.jp>,
Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
>Hi,
>
>In message "Re: Range#length?"
>    on 03/02/13, William Djaja Tjokroaminata <billtj / y.glue.umd.edu> writes:
>
>|How about "sup" and "inf"?  Using '{}' notation for set, '()' for open
>|interval, and '[]' for closed internval, then
>|
>|    {40, 41, 42}   .sup   >> 42
>|    (40.0, 42.0)   .sup   >> 42.0
>|    [40.0, 42.0]   .sup   >> 42.0
>
>I'm not sure what "sup" and "inf" stand for.
>
>							matz.


For me, the right way to think about a range you can iterate over is a a
nice  compact notation/implementation  for a  particular kind  of array.
After all,

  (0..5).each { |i| ...

has the same effect as

  [0,1,2,3,4,5].each {|i| ...

and

  (0...5).each { |i| ...

has the same effect as

  [0,1,2,3,4].each {|i| ...

so it is clear to me that one should have:

  (0..5).length == 6
  (0...5).length == 5
  (0..5).max == 5
  (0...5).max == 4
  (0..5).min == 0

etc...
For me, this kind of equivalence with arrays
  (1) suppresses the need to invent new method names
  (2) makes ranges more useful (applicable in more situations).

Now,  I will  not  comment on  suitable methods  for  ranges you  cannot
iterate over (float ranges?). But the above is my philosophy on suitable
methods for ranges *you can iterate over*.

What do you think?