to_h

hsh.to_h â hsh or new_hash Instance Public methods Returns self. If called on a subclass of Hash, converts the receiver to a Hash object.

to_a

hsh.to_a â array Instance Public methods Converts hsh to a nested array of [ key, value ] arrays. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_a #=> [["c", 300], ["a", 100], ["d", 400]]

store

hsh.store(key, value) â value Instance Public methods Element Assignment Associates the value given by value with the key given by key. h = { "a" => 100, "b" => 200 } h["a"] = 9 h["c"] = 4 h #=> {"a"=>9, "b"=>200, "c"=>4} key should not have its value changed while it is in use as a key (an unfrozen String passed as a key will be duplicated and frozen). a = "a" b = "b".freeze h = { a => 100, b => 200 } h.key(100).equal? a #=> false h.key(200).equal?

size

hsh.size â fixnum Instance Public methods Returns the number of key-value pairs in the hash. h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 } h.length #=> 4 h.delete("a") #=> 200 h.length #=> 3

shift

hsh.shift â anArray or obj Instance Public methods Removes a key-value pair from hsh and returns it as the two-item array [ key, value ], or the hash's default value if the hash is empty. h = { 1 => "a", 2 => "b", 3 => "c" } h.shift #=> [1, "a"] h #=> {2=>"b", 3=>"c"}

select!

hsh.select! {| key, value | block } â hsh or nilhsh.select! â an_enumerator Instance Public methods Equivalent to Hash#keep_if, but returns nil if no changes were made.

select

hsh.select {|key, value| block} â a_hashhsh.select â an_enumerator Instance Public methods Returns a new hash consisting of entries for which the block returns true. If no block is given, an enumerator is returned instead. h = { "a" => 100, "b" => 200, "c" => 300 } h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300} h.select {|k,v| v < 200} #=> {"a" => 100}

replace

hsh.replace(other_hash) â hsh Instance Public methods Replaces the contents of hsh with the contents of other_hash. h = { "a" => 100, "b" => 200 } h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}

reject!

hsh.reject! {| key, value | block } â hsh or nilhsh.reject! â an_enumerator Instance Public methods Equivalent to Hash#delete_if, but returns nil if no changes were made.

reject

hsh.reject {| key, value | block } â a_hashhsh.reject â an_enumerator Instance Public methods Same as Hash#delete_if, but works on (and returns) a copy of the hsh. Equivalent to hsh.dup.delete_if.