For your information, member? used to iterate over
? items to check membership. But since confusion
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’
irb(main):002:0> s < s.succ
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
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
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 B.