-
Notifications
You must be signed in to change notification settings - Fork 97
Fix <=> for IPv4 and IPv6. #76
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
Conversation
|
Raising has the benefit that we know that an invalid comparison between unlike types has occurred. If we return ip1 = IPAddress('192.168.1.1')
ip2 = '192.168.1.1'
if ip1.eql?(ip2)
# blah
end |
|
Your code snippet does not currently raise an exception :-) it returns
My point is that with Ruby 2.2.0 (at least), the (The first bunch of issues ( Because the behavior will change in the future, it should make sense to have the |
|
related: RubyMoney/money#528 |
|
Returning |
|
@francisluong, I have removed my branch quite some time ago and can't reconnect this work to the PR. I created another branch for testing purpose and the test suite passes. This should unblock some issues 😉 |
francisluong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved based on previous tests. Also... confirmed "If the other object is not comparable then the <=> operator should return nil."
Comparing
IPAddress::IPv4orIPAddress::IPv6instances against another class currently raises an exception… Returningnilis more appropriate since"42" <=> 42 #=> nil.