Ah, I see. You can handle this using Enumerable's invoke. This code should
make it clear:
a = new Hash({ x : "foo", y : "bar" });
b = new Hash({ x : "zam", y : "moof" });
a.get("x");
"foo"
b.get("x");
"zam"
[a,b].invoke("get","x");
["foo", "zam"]
[a,b].invoke("unset","x")
["foo", "zam"]
a.get("x")
(undefined)
Cheers,
Alex
On Thu, Apr 8, 2010 at 3:24 PM, chrysanthe m <[email protected]> wrote:
> Sorry sudden send resume in this reply
>
> Hello
> I am having a difficult time trying to enumerate a hash to determine if a
> give key is in the hash and if so delete it and its value.
> If I could approach it index it would be
> function remove(valueToTest, hashToBeTested){
> for(i=0;i<hashToBeTested.length;i++){
> if(valueToTest==hashToBeTested[i]) hashToBeTested.unset(valueToTest);
> }
>
> Would I do it like
>
> hashToBeTested.each(function(valueToTest){
> if(valueToTest==this)hashToBeTested.unset(valueToTest);
> },hashToBeTested);
> return hashToBeTested;
>
>
> which I am sure is wrong syntactically if not semantically. Can someone
> guide the proper way and more deeply the use of this?
>
>
> On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m <[email protected]>wrote:
>
>>
>>
>
> --
> 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]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
--
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.