Fix <=> for IPv4 and IPv6.#76
Fix <=> for IPv4 and IPv6.#76francisluong merged 1 commit intoipaddress-gem:masterfrom smortex:spaceship_compare
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.
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.