Hi,
I'm surprised the loop didn't work, it seems to:
http://jsbin.com/ejeju4/2
Or you could add your own `clear` function, but you'd want to be sure
to check with each Prototype dot release that the implementation
didn't need to be tweaked:
* * * *
// Add Hash#clear
// Note that this must be RECHECKED on every Prototype dot release
// to ensure that the internals haven't changed.
(function() {
function Hash_clear() {
this._object = {};
}
Hash.prototype.clear = Hash_clear;
})();
* * * *
http://jsbin.com/ibipe4
I would _not_ suggest just doing hashBrown._object = {}; inline in
your code. Define a method and check the implementation on every dot
release, so there's only one place to add it.
I _know_ I've seen discussion of adding a #clear method to hash, but I
don't recall the result. As it's not in 1.7, maybe someone thought it
wasn't a good idea, but it seems like an odd omission to me. I've done
a ticket in Lighthouse[1] offering to do a patch on git (for 1.7.1,
not 1.7.0) if people do want it.
[1]
https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/1158-add-hashclear
FWIW,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com