Hey Emma,
What exactly do you call a hash? A *Hash* instance? Or just a good ol'
JavaScript object? Or even an Array, perhaps?
Now, if you're indeed using a Hash, look at the docs to see that
enumerating a hash gets the *pairs*, not the values alone. So you'd
need to access the pair's 1-indexed property, or "value" property
(they're basically the same, in two notations), and call your method on it.
var h = new Hash();
h['john'] = new Player('john');
h['mary'] = new Player('mary');
h.each(function(pair) { pair[1].something(); });
// or:
h.each(function(pair) { pair.value.something(); });
Because of this, invoke won't work as expected, since it requires the
invoked method to be present in the passed object. But you can trick it:
h.pluck('value').invoke('something');
Check out the docs for these:
http://prototypejs.org/api/hash/each
http://prototypejs.org/api/enumerable/invoke
http://prototypejs.org/api/enumerable/pluck
'HTH,
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---