From: Warren Brown Date: 2005-11-24T01:03:19+09:00 Subject: Re: [BUG] string range membership Matz, > For your information, member? used to iterate over ? items to check membership. But since confusion > between include? and member?, they were merged. The > point is Ranges are used both for ranges and > intervals. Sometimes users want it to behave like a > range surrounded by begin/end values. Sometimes they > want it to behave like a set of values, that #each > produces. > > I'd like to care this issue, but I haven't know the > right way to solve it yet. Perhaps we should > provide both membership method, with right names for > each. Any ideas? Ah, I see. So really, the root problem here is the assumption by Range that (value < value.succ). And in String, this assumption does not always hold true: irb(main):001:0> s = 'z' => "z" irb(main):002:0> s < s.succ => false Because of that, there is a huge distinction between str_range.to_a.member?(x) (is x a member of the set of the range's values) and (str_range.first <= x <= str_range.last) (is x in the range's interval). So, given that (at least in the case of ranges of strings) there is a clear distinction between a value being included in the interval and a value being included in the set, it appears that we have a real need for two different methods. The methods Range#include? (in interval) and Range#member? (of set) seem to be perfect candidates for these two different functionalities. Before these two methods were merged, did they take on these two functionalities, or were they different in some other way? Are there other cases where "membership" changes depending on whether the range is viewed as a set or an interval? If not, perhaps it would be better to address the fact that str.succ violates the (str < str.succ) assumption. Perhaps the functionality currently in String#succ could be moved to another method (String#increment perhaps?), and String#succ could take on a new functionality that does not violate (str < str.succ). Anyway, please let me know if there is anything I can do to help settle this issue. - Warren Brown