From: Florian Frank Date: 2004-10-05T20:11:52+09:00 Subject: Re: [RCR] New [] Semantics On 05.10.2004, at 11:59, Brian Candler wrote: > On Tue, Oct 05, 2004 at 06:19:09PM +0900, trans. (T. Onoma) wrote: >> I occurs to me that the angry villagers might be confused. The >> example of the >> never ending >> >> (0..(10.0/0)).member?(4) >> >> comes to mind. Why would this be an infinite loop? It must be trying >> to >> generate the list before looking to see if 4 is in it (?) > > Yes, see adjacent thread. What it actually does is iterate all value > from > start to end using succ, and set a flag to true when it finds a match > (but > it doesn't break out of the loop when a match is found) This seems the wrong thing to do. The documentation says: ---------------------------------------------------------- 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). I would think that it should return true, instead of going round in circles. I can understand that include? was overridden, because there is a more efficient way to check for inclusion in ranges and it makes a lot of sense for ranges of Floats. The Enumerable version works ok: >> Enumerable.instance_method(:member?).bind(0..(1.0/0)).call(4) => true I would prefer getting rid of the overriden member? implementation in range.c. Florian Frank