Hi, > I'm surprised the loop didn't work, it seems to: > http://jsbin.com/ejeju4/2
Sorry, that link was wrong. It should be: http://jsbin.com/ejeju4 -- T.J. On Oct 21, 7:51 am, "T.J. Crowder" <[email protected]> wrote: > Hi, > > On Oct 21, 3:39 am, chrysanthe m <[email protected]> wrote: > > > Hello > > How do I clear a prototype hash? I have finally tried and failed with below > > after trying hashBrown.length=0 and hashBrown.clear(). > > hashBown.each(function(key) { > > hashBrown.unset(key); > > }); > > 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/1... > > FWIW, > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
