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

IPv? and Prefix? classes don't work as expected in hashes and sets #21

Open
patdowney opened this issue May 29, 2012 · 1 comment
Open
Assignees

Comments

@patdowney
Copy link

In the following examples I would expect the set to only have one entry and the hash to only have one key (note: if it's the same object instance you won't see this behaviour).

require 'set'
require 'ipaddress'

# works as expected
net =  IPAddress.parse('192.168.0.0/24')
s = Set.new
s.add net
s.add net
puts s.length # => 1

# doesn't work as expected
s = Set.new
s.add IPAddress.parse('192.168.0.0/24')
s.add IPAddress.parse('192.168.0.0/24')
puts s.length # => 2, should be 1?

# likewise with hashes
# works as expected
net =  IPAddress.parse('192.168.0.0/24')
h = {}
h[net] = true
h[net] = false
puts h.length # => 1

# doesn't work as expected
h = {}
h[IPAddress.parse('192.168.0.0/24')] = true
h[IPAddress.parse('192.168.0.0/24')] = false
puts h.length # => 2, should be 1?
@patdowney
Copy link
Author

Pull request with fix raised (Issue #22)

@mikemackintosh mikemackintosh self-assigned this Mar 24, 2015
TheHolyRoger pushed a commit to whatagem/ipaddress that referenced this issue Oct 18, 2021
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

2 participants