# Re: string range membership

**URL:** <https://www.ruby-forum.com/t/re-string-range-membership/100717>\
**Category:** Ruby\
**Created:** [November 23, 2005, 4:06pm UTC](https://www.ruby-forum.com/t/re-string-range-membership/100717 "2005-11-23T16:06:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![warrenbrown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@warrenbrown](https://www.ruby-forum.com/u/warrenbrown)\
**Post date:** [November 23, 2005, 4:06pm UTC](https://www.ruby-forum.com/t/re-string-range-membership/100717/1 "2005-11-23T16:06:16Z")

</div>

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.
```

---

<div class="post-metadata">

**Author:** ![warrenbrown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@warrenbrown](https://www.ruby-forum.com/u/warrenbrown)\
**Post date:** [November 23, 2005, 8:16pm UTC](https://www.ruby-forum.com/t/re-string-range-membership/100717/2 "2005-11-23T20:16:25Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![warrenbrown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@warrenbrown](https://www.ruby-forum.com/u/warrenbrown)\
**Post date:** [November 23, 2005, 9:08pm UTC](https://www.ruby-forum.com/t/re-string-range-membership/100717/3 "2005-11-23T21:08:52Z")

</div>

s/it String is/in String it/
