keep_if

hsh.keep_if {| key, value | block } â hshhsh.keep_if â an_enumerator Instance Public methods Deletes every key-value pair from hsh for which block evaluates to false. If no block is given, an enumerator is returned instead.

key

hsh.key(value) â key Instance Public methods Returns the key of an occurrence of a given value. If the value is not found, returns nil. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300 } h.key(200) #=> "b" h.key(300) #=> "c" h.key(999) #=> nil

key?

hsh.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

keys

hsh.keys â array Instance Public methods Returns a new array populated with the keys from this hash. See also Hash#values. h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 } h.keys #=> ["a", "b", "c", "d"]

length

hsh.length â 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

member?

hsh.member?(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

merge

hsh.merge(other_hash) â new_hashhsh.merge(other_hash){|key, oldval, newval| block} â new_hash Instance Public methods Returns a new hash containing the contents of other_hash and the contents of hsh. If no block is specified, the value for entries with duplicate keys will be that of other_hash. Otherwise the value for each duplicate key is determined by calling the block with the key, its value in hsh and its value in other_hash. h1 = { "a" => 100,

merge!

hsh.merge!(other_hash) â hshhsh.merge!(other_hash){|key, oldval, newval| block} â hsh Instance Public methods Adds the contents of other_hash to hsh. If no block is specified, entries with duplicate keys are overwritten with the values from other_hash, otherwise the value of each duplicate key is determined by calling the block with the key, its value in hsh and its value in other_hash. h1 = { "a" => 100, "b" => 200 } h2 = { "b" => 254,

pretty_print

pretty_print(q) Instance Public methods

pretty_print_cycle

pretty_print_cycle(q) Instance Public methods