Forum: Ruby Re: string range membership

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dbda3094a2f929a0658bedd4e0787a56?d=identicon&s=25 warrenbrown (Guest)
on 2005-11-23 16:06
(Received via mailing list)
T,

> This was discussed sometime ago. The solution (mostly
> arrived at by Peter Vanbroekhoven) 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 Brown
45196398e9685000d195ec626d477f0e?d=identicon&s=25 transfire (Guest)
on 2005-11-23 20:16
(Received via mailing list)
> 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.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 transfire (Guest)
on 2005-11-23 21:08
(Received via mailing list)
s/it String is/in String it/
This topic is locked and can not be replied to.