Re: string range membership


#1

T,

This was discussed sometime ago. The solution (mostly
arrived at by Peter V.) is to use a
different comparision method.

I can't find this discussion in the archive.  Can you give me a link

or a message number?

- Warren B.

#2

I can’t find this discussion in the archive. Can you give me a link
or a message number?

Largely from Ruby-talk 115120, although the solution really came about
on the old suby-muse mailing list.

I’m not sure everyone understood me though. The problem is that
String’s #<=> and #succ methods are not compatible. Therefore
Range#member? and Rage#include? which use #<=> can not provide proper
results for String-based Ranges. The solution is to have Range use a
different comparision method, namely #cmp. In most classes #cmp will of
course just be an alias for #<=>, but it String is would differ to be
compatible with #succ, and then #include and #member would be correct.
Q.E.D.

T.


#3

s/it String is/in String it/