On Saturday 09 October 2004 02:34 pm, Brian Candler wrote:
| >   Inf = 1.0/0
| >   (3..Inf).to_a.include?(5)
|
| But that's unlikely to be useful anyway, even with the current member?
| syntax, since it either returns true or hangs in an infinite loop:
|
|     (3..Inf).member?(1)
|
| [Actually Ruby hangs in an infinite loop even if the value is found, but
| Matz has acknowledged that as a bug]

Granted. 

I have given the usage question some thought. I think the most common uses are 
1) for Interval, then 2) as Array index, then 3) simple iterator on Integers. 
Please let me know if you can think of any other common use cases. For 1 and 
2 all that really matters is the two bound points.

Note: Consider a special EvenInt class with a succ of: {|x| x+2}, make a Range 
of those and use it as an Array index argument,

   arr = [1,2,3,4,5,6,7,8]
   arr[EvenInt.new(2)..EvenInt.new(4)]

would you expect [2,3,6,8]? I haven't tried it but my bet is you'll get 
[2,3,4,5,6,7,8] instead.

Now, consider, how often have you use any of these on a Range:

  collect, detect, each_with_index, entries, 
  find, find_all, grep, map, member?,
  reject, select, sort

So maybe Enumerable isn't really needed in Range, and would work just fine 
with only a couple of useful methods toward that end, like a specially 
defined #each --I'm not even sure #succ is really a good match for this 
either.

For all those much less common Enumerable uses of a Range, one would be better 
off using a dedicated class anyway --a real Iterator. So why not just provide 
one of those in the standard libs, instead of trying to get Range to serve 
triple duty. 

Clearly this is the direction things are headed anyway.

T.