Sha256: 68b2fb67e54a698c1d2fb579b8b90212a5680fc8b67b47129c8fda2f78be4cad
Contents?: true
Size: 537 Bytes
Versions: 3
Compression:
Stored size: 537 Bytes
Contents
#-- # Adapted from rand.rb by: # * Ilmari Heikkinen <mailto:kig@misfiring.net> # * Christian Neukirchen <mailto:chneukirchen@gmail.com> #++ require 'facet/hash/rand_pair' class Hash # Deletes a random key-value pair and returns that pair. # # require 'facet/hash/at_rand' # # a = {:one => 1, :two => 2, :three => 3} # a.rand_pair! #=> [:two, 2] # a #=> {:one => 1, :three => 3} # def rand_pair! k,v = rand_pair delete( k ) return k,v end alias_method( :pick_pair, :rand_pair! ) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.0 | lib/facet/hash/rand_pair%21.rb |
facets-0.7.1 | lib/facet/hash/rand_pair%21.rb |
facets-0.7.2 | lib/facet/hash/rand_pair%21.rb |