eql?

hash.eql?(other) â true or false Instance Public methods Returns true if hash and other are both hashes with the same content.

fetch

hsh.fetch(key [, default] ) â objhsh.fetch(key) {| key | block } â obj Instance Public methods Returns a value from the hash for the given key. If the key can't be found, there are several options: With no other arguments, it will raise an KeyError exception; if default is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned. h = { "a" => 100, "b" => 200 } h.fetch("a") #=&

flatten

hash.flatten â an_arrayhash.flatten(level) â an_array Instance Public methods Returns a new array that is a one-dimensional flattening of this hash. That is, for every key or value that is an array, extract its elements into the new array. Unlike Array#flatten, this method does not flatten recursively by default. The optional level argument determines the level of recursion to flatten. a = {1=> "one", 2 => [2,"two"], 3 => "three"} a.flatten # => [1, "one", 2, [2,

has_key?

hsh.has_key?(key) â true or false Instance Public methods Returns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false

has_value?

hsh.has_value?(value) â true or false Instance Public methods Returns true if the given value is present for some key in hsh. h = { "a" => 100, "b" => 200 } h.has_value?(100) #=> true h.has_value?(999) #=> false

hash

hsh.hash â fixnum Instance Public methods Compute a hash-code for this hash. Two hashes with the same content will have the same hash code (and will compare using eql?).

include?

hsh.include?(key) â true or false Instance Public methods Returns true if the given key is present in hsh. h = { "a" => 100, "b" => 200 } h.has_key?("a") #=> true h.has_key?("z") #=> false

initialize_copy

initialize_copy(p1) Instance Public methods

inspect

hsh.to_s â stringhsh.inspect â string Instance Public methods Return the contents of this hash as a string. h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_s #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}" to_s

invert

hsh.invert â new_hash Instance Public methods Returns a new hash created by using hsh's values as keys, and the keys as values. h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 } h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"}