From ab5a19a1c1199f4bee60f90d9163af6e906e94f0 Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Thu, 10 Sep 2009 15:07:28 +0100 Subject: [PATCH] doc: Merged old docs for Hash#merge, updated example. --- src/lang/hash.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lang/hash.js b/src/lang/hash.js index 6088d18..26c79fe 100644 --- a/src/lang/hash.js +++ b/src/lang/hash.js @@ -176,10 +176,22 @@ var Hash = Class.create(Enumerable, (function() { /** * Hash#merge(object) -> Hash + * - object (Object | Hash): The object to merge with this hash to produce + * the resulting hash. + * + * Returns a new `Hash` instance with `object`'s key/value pairs merged in; + * this hash remains unchanged. * - * Returns a new hash with `object`'s key/value pairs merged in. * To modify the original hash in place, use [[Hash#update]]. * + * ### Example + * + * var h = $H({one: "uno", two: "due"}); + * var h2 = h.merge({three: "tre"}); + * h.keys(); + * // -> ["one", "two"] (unchanged) + * h2.keys(); + * // -> ["one", "two", "three"] (has merged contents) **/ function merge(object) { return this.clone().update(object);