Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why <=> returns false for invalid comparison? #39

Open
FranklinYu opened this issue Aug 28, 2016 · 2 comments
Open

Why <=> returns false for invalid comparison? #39

FranklinYu opened this issue Aug 28, 2016 · 2 comments
Assignees

Comments

@FranklinYu
Copy link

If <=> returns nil for invalid comparison, we can reuse the standard Comparable module, which has been available since at least 1.9.3. Any use case for that? I think most people would just use other derived operators, instead of directly use <=>.

@gshutler
Copy link
Owner

gshutler commented Aug 30, 2016

It looks like the custom Comparable module comes from the first commit so I'm not sure why it's done that way.

Changing it for a nil returning implementation breaks several specifications so it's not a simple fix but I think it is a good idea to explore.

@gshutler gshutler self-assigned this Aug 30, 2016
@FranklinYu
Copy link
Author

Yes, it is not expected to be a simple fix. I think it may even break backward compatibility (if anyone is really using this operator). Hard choice.

gshutler added a commit that referenced this issue Sep 5, 2016
Removes the custom Comparable implementation and changes internal
<=> implementations to return nil when the two objects cannot be
compared to satisfy the standard Comparable interface.

Resolves #39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@gshutler @FranklinYu and others