```Hi --

On Thu, 1 Dec 2005, Bob Showalter wrote:

> Dave Howell wrote:
>> English speaker.
>>
>> Relative new Ruby user.
>>
>> My thoughts: forget it! Stop! Ahhhh! Kitchen sink!
>>
>> Let's see if I've got this straight. Somebody complained because
>>
>>     ('1'..'10').member?('2')
>>     => false
>>
>>
>> Good!
>
> No, not good.
>
> Range mixes Enumerable, but Range#member? does not behave like
> Enumerable#member?, hence the confusion.
>
>> The fact that Ruby will get incredibly clever with strings and
>> fabricate arbitrary sequences with them is a charming trick, but they are
>> arbitrary, and it is a trick.
>>
>> The fact that '1', '2', ... '9','10'  is obvious doesn't make it any less
>> arbitrary.
>
> Yes, it is arbitrary, but nevertheless, the range '1'..'10' will produce the
> value '2' (unless String#succ has been overridden), so '2' is by any
> ordindary definition of the word member, a member of this range.

I think it's more a question of the definition of the word "range".
I've come to believe that ranges should be strictly interval-like in
their behavior.  Basically, a range is a kind of filter: (0...10) is
not ten numbers, but rather an expression of "the fact of
0-through-10-ness", or something like that.  At least, that's how I'd
like to see ranges work.  I think they're trying to be too many
things at once.

This is also why I think the idea of a mutable range is a
contradiction in terms.  You can't change what the fact of starting at
0 and ending at 10 means.

David

>>     ('1'..'10').to_a.member?('2')
>>     => true
>>
>> Is that really such a big deal?
>>
>
> No, that's fine. More efficient would be
>
>  !('1'..'10').find({|x| x == '2'}).nil?

I don't think find takes a hash argument :-)  Also, why not lose the !
and the .nil? ?

David

--
David A. Black
dblack / wobblini.net

```