You can call both constructor methods without arguments, too; they will assume an empty hash.
each(iterator) -> Hash Iterates over the name/value pairs in the hash.
This is actually the each method from the mixed-in Enumerable module. It is documented here to illustrate the structure of the passed first argument, and the order of iteration.
Pairs are passed as the first argument of the iterator, in the form of objects with two properties:
1. key, which is the key name as a String
2. value, which is the corresponding value (and can, possibly, be undefined)
The order of iteration is browser-dependent, as it relies on the native for…in loop. It is possible to have function values in a hash, though the iteration skips over Hash and Enumerable methods (naturally). More precisely, it skips the properties found on the object’s prototype.
merge(hash) -> alteredHash Injects all the pairs in the given hash into the current one, which is then returned.
Duplicate keys will cause an overwrite (the argument hash prevails), and new keys from the argument hash are also used. This is useful for selectively overwriting values on specific keys (e.g. exerting some level of control over a series of options).
Note the argument needs not be a Hash object, as it it will get passed to the $H function anyway, to ensure compatibility.
toQueryString() -> String Turns a hash into its URL-encoded query string representation.
This is a form of serialization, and is mostly useful to provide complex parameter sets for stuff such as objects in the Ajax namespace (e.g. Ajax.Request).
The order of pairs in the serialized form is not guaranteed (and mostly irrelevant anyway), except for array-based parts, which are serialized in array order.
values() -> Array Collect the values of a hash and returns them in an array.
The order of values is browser implementation-dependent (based on the for…in loop on keys), so—although most of the time you will see it as consistent—it’s better not to rely on a specific order. Also remember that the hash may contain values such as null or even undefined.