From 1910e08a79eb6a3cdc0cad86a9b8b2dfce8b8149 Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Thu, 10 Sep 2009 15:42:04 +0100 Subject: [PATCH] doc: Merged and updated old docs for Hash#update. --- src/lang/hash.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lang/hash.js b/src/lang/hash.js index 3f71de7..3f020ea 100644 --- a/src/lang/hash.js +++ b/src/lang/hash.js @@ -232,10 +232,22 @@ var Hash = Class.create(Enumerable, (function() { /** * Hash#update(object) -> Hash + * - object (Object | Hash): The object to merge with this hash to produce + * the resulting hash. * - * Updates hash with the key/value pairs of `object`. - * The original hash will be modified. To return a new hash instead, use + * Updates a hash *in place* with the key/value pairs of `object`, returns + * the hash. + * + * `update` modifies the hash. To get a new hash instead, use * [[Hash#merge]]. + * + * ### Example + * + * var h = $H({one: "uno", two: "due"}); + * h.update({three: "tre"}); + * // -> h (a reference to the original hash) + * h.keys(); + * // -> ["one", "two", "three"] (has merged contents) **/ function update(object) { return new Hash(object).inject(this, function(result, pair) {