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. It sounds more like your beef is with String#succ > I'd so much rather have > one way, with one thorough explanation, and notes on its shortcomings, > than seven, or whatever, each with just a sketchy description. I would too, namely make Enumerable#member? work the same way for Ranges that it does for any other Enumerable. (That seems to be where matz is leaning). > ... > In closing: > ('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?