Matt
unread,Nov 5, 2009, 9:11:28 AM11/5/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prototype & script.aculo.us
I believe I've tried this enough to say with certainty that using a
hash constructor followed immediately by the set() method does not
work, properly at least. In fact, it does add the value to the hash,
but not under any key, just directly off the main tree without a key.
I think this behavior should either be stopped or fixed (unless I'm
missing something).
var anotherHash = $H(a:'apple', b:'banana')
var newHash = $H().set('this', anotherHash)
Expected result...
// -> #<Hash:{'this':{'a':'apple', 'b':'banana'}}>
Actual result...
// -> #<Hash:{'a':'apple', 'b':'banana'}>
Using "new Hash().set()" of course has the same results.
The workaround for me was to make a function to create my hashes on
one line.
newHash(key, value) {
var h = new Hash()
h.set(key, value)
return h
}
Note how if you combine ANY of those three lines of code, you'll get
the broken hash. Interesting?