Hash
self[key]
Returns the value mapped to key. If the corresponding key is not registered, returns the default value (or nil if not specified).
self[key]=value
Maps value to key. Returns value.
clear
Clears the hash contents. Returns self.
clonedup
Returns a new hash with the same contents as the receiver. Using clone on a frozen hash will return a similarly frozen hash, but dup returns an unfrozen hash with identical contents.
Returns value.
delete(key)delete(key) {|key| ... }
Deletes the mapping from key. Returns the removed value, or nil if there is no value corresponding to key.
When the method has been supplied with a block, it will be evaluated and the results returned if there is no match for key.
each {|key, value| ... }each_pair {|key, value| ... }
Evaluates a block with key and value as arguments. Returns self.
each_key {|key| ... }
Evaluates a block with key as the argument. Returns self.
each_value {|value| ... }
Evaluates a block with value as the argument. Returns self.
empty?
Returns true when the hash is empty.
has_key?(key)include?(key)
Returns true when the hash includes key as a key.
has_value?(value)
Returns true when the hash includes value as a value as determined by ==.
index(val)
Returns the key corresponding to val. If there is no corresponding element, returns nil.
If there are multiple corresponding keys, arbitrarily returns one of them.
keys
Returns an array of all keys.
lengthsize
Returns the number of elements in the hash.
values
Returns an array of all values in the hash.
Last updated