clear

count

Returns the number of elements in the hash. Also useful to check for a nonempty hash, because count returns a true (nonzero) value if there is something in the hash: has_options => 'count'.

This method does not accept any arguments.

is_empty

If the hash is populated, returns false. Otherwise, returns true.

This method does not accept any arguments.

accessor($key)

accessor($key, $value)

If passed one argument, returns the value of the specified key. If passed two arguments, sets the value of the specified key.

When called as a setter, this method returns the value that was set.

shallow_clone

This method returns a shallow clone of the hash reference. The return value is a reference to a new hash with the same keys and values. It is shallow because any values that were references in the original will be the same references in the clone.

Why no each?

We have deliberately omitted a method for each, due to its stateful interaction with the hash iterator. Using keys or kv is much safer.