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

Unit instances uniqueness (#hash) #126

Closed
jackcasey opened this issue May 2, 2015 · 0 comments
Closed

Unit instances uniqueness (#hash) #126

jackcasey opened this issue May 2, 2015 · 0 comments

Comments

@jackcasey
Copy link

Is this expected behaviour? FYI tested in ruby-units (1.4.3.7)

2.1.3 :001 > require "ruby_units"
true
2.1.3 :002 > ["2 kg".u, "2 kg".u].uniq
[
    [0] 2 kg,
    [1] 2 kg
]
2.1.3 :003 > "2 kg".u.hash
-2367612910358029872
2.1.3 :004 > "2 kg".u.hash
-1398046655738998000

To me this seems like a bug. Identical ruby unit instances (that are eql?) should hash to the same value right? (So .uniq? and any other operations that check the hash should work)

But I might be missing something subtle...

deancoopercode added a commit to deancoopercode/ruby-units that referenced this issue Nov 4, 2016
deancoopercode added a commit to deancoopercode/ruby-units that referenced this issue Nov 4, 2016
deancoopercode added a commit to deancoopercode/ruby-units that referenced this issue Nov 6, 2016
Ruxton pushed a commit to Ruxton/ruby-units that referenced this issue Nov 23, 2016
olbrich pushed a commit that referenced this issue Nov 25, 2016
* Test coverage for issue #126 
* Ensure objects with the same value return the same hash - Fixes Issue #126
@olbrich olbrich closed this as completed Dec 30, 2016
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