# Are the docs correct for spaceship \<=\> in String?

**URL:** <https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898>\
**Category:** Ruby\
**Created:** [December 4, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898 "2008-12-04T22:27:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 4, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898/1 "2008-12-04T22:27:21Z")

</div>

Hello all,

First-time poster… I apologize if I am posting to the wrong group.

I am teaching a class of high-schoolers in programming, using Ruby. I  
gave them an exercise called “Stupid String Tricks” which was about  
getting them comfortable using the online documentation for Ruby. The  
assignment was to do five silly things with Strings and share their  
results with the class.

While walking through the docs online during class, we decided to dig  
into \<=\> and demonstrate how it works and how to interpret the docs.  
We used this page:

[http://www.ruby-doc.org/core/classes/String.html#M000778](http://www.ruby-doc.org/core/classes/String.html#M000778)

I thought that page was the authoritative one.

I believe the operator/method behaves correctly, but believe the doc  
is not correct.

str \<=\> other\_str =\> -1, 0, +1

Comparison—Returns -1 if other\_str is less than, 0 if other\_str is  
equal to, and +1 if other\_str is greater than str.

Isn’t it the other way around? Shouldn’t the return be -1 if str is  
less than other\_str? The class behavior and the examples in the docs  
all behave that way.

If this is not the right place to get visibility for this, what is?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 4, 2008, 10:45pm UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898/2 "2008-12-04T22:45:35Z")

</div>

whats funny, is that the text of the documentation is wrong while the  
examples are showing the right behaviour.  
I’m sure somebody on this list as autoritative power on this doc!

2008/12/4 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 6, 2008, 12:25am UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898/3 "2008-12-06T00:25:28Z")

</div>

On Dec 5, 4:21 pm, Gregory B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Technical Blaag at:[http://blog.majesticseacreature.com](http://blog.majesticseacreature.com)  
> Non-tech stuff at:[http://metametta.blogspot.com](http://metametta.blogspot.com)  
> “Ruby Best Practices” Book now in O’Reilly Roughcuts:[http://rubybestpractices.com](http://rubybestpractices.com)

Thanks. I just filed a bug.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 6, 2008, 12:51am UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898/4 "2008-12-06T00:51:14Z")

</div>

> > > whats funny, is that the text of the documentation is wrong while the  
> > > examples are showing the right behaviour.

Ouch. Glad to know that the behaviour is right, only the docs are  
wrong. I was wondering if some code I made with that was running ok.  
🙂

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 5, 2008, 10:28pm UTC](https://www.ruby-forum.com/t/are-the-docs-correct-for-spaceship-in-string/154898/5 "2008-12-05T22:28:15Z")

</div>

On Thu, Dec 4, 2008 at 4:38 PM, Louis-Philippe [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> whats funny, is that the text of the documentation is wrong while the  
> examples are showing the right behaviour.  
> I’m sure somebody on this list as autoritative power on this doc!

You can subscribe and post to ruby-core, and/or file a ticket in Ruby’s  
tracker:

> **[Ruby Issue Tracking System](https://redmine.ruby-lang.org/)**
>
> Redmine

-greg
