Skip to content

Instantly share code, notes, and snippets.

@paul
Created October 3, 2008 18:02
Show Gist options
  • Save paul/14596 to your computer and use it in GitHub Desktop.
Save paul/14596 to your computer and use it in GitHub Desktop.
irb(main):002:0> require 'uuidtools'
=> true
irb(main):003:0> u = UUID.random_create
=> #<UUID:0x-24390924 UUID:961537fc-4670-4088-a25d-814723d998e1>
irb(main):004:0> [u]
=> [#<UUID:0x-24390924 UUID:961537fc-4670-4088-a25d-814723d998e1>]
irb(main):005:0> [u].hash
RangeError: bignum too big to convert into `long'
irb(main):006:0> u.hash
=> 199494373121591421883459330646478526689
# It looks like Array.hash does ( 2 ** u.hash ), which is a huge number, and breaks:
irb(main):007:0> (2 ** u.hash)
/usr/lib/ruby/1.8/rational.rb:527: warning: in a**b, b may be too big
=> Infinity
See http://www.ruby-doc.org/core/classes/Array.src/M002182.html for Array#hash source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment