Project

General

Profile

Misc #15630

Clarification on Comparable documentation

Added by shugo (Shugo Maeda) 4 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:91650]

Description

The documentation of Comparable#> says:

/*
 *  call-seq:
 *     obj > other    -> true or false
 *
 *  Compares two objects based on the receiver's <code><=></code>
 *  method, returning true if it returns 1.
 */

However, Comparable#> returns if and only if <=> returns any value greater than 0.
It's better to fix the documentation, isn't it?

Associated revisions

Revision f005ccc7
Added by shugo (Shugo Maeda) 2 months ago

Clarify requirements of <=>

A return value of <=> is automatically converted to -1, 0, or 1, so
other values can be returned. [Misc #15630]

History

#1

Updated by shugo (Shugo Maeda) 4 months ago

  • Subject changed from Clarifications on Comparable documentation to Clarification on Comparable documentation
#2

Updated by shugo (Shugo Maeda) 2 months ago

  • Status changed from Open to Closed

Applied in changeset commit:ruby-git|f005ccc771574e8e4e17b7a35c19b352e0b7dc73.


Clarify requirements of <=>

A return value of <=> is automatically converted to -1, 0, or 1, so
other values can be returned. [Misc #15630]

Also available in: Atom PDF