I'm sorry, but I don't understand your questions.

Maybe I can explain what these lines say:
1- this is a loop, like :       "Take every pair of the Hash referenced as 
HashtoBeTested" 
Remember that a Hash is a collection of pairs. Each pair is composed of a key 
and a value  
2- for every pair, compare the value of the pair with ValueToTest
3- if they are equal, then remove this pair from the Hash
For such a removal, you have to identify the pair by its key, and not by its 
value

Hope this helps,

Le 14 avr. 2010 à 15:38, chrysanthe m a écrit :

> Hi Christophe
> Thanks, but is there anything more to the syntax.  Also how do you use that 
> optional context parameter with this within the loop and for what enhanced 
> value/processing does it give you?
> 
> On Mon, Apr 12, 2010 at 4:59 AM, Christophe Decaux 
> <christophe.dec...@gmail.com> wrote:
> If I understand well, what you're asking for is pretty close to what you 
> suggested in your original post:
> 
> hashToBeTested.each(function(pair){
>   if(valueToTest==pair.value){
>     hashToBeTested.unset(pair.key);
>   }
> }
> 
> 
> Christophe
> 
> Le 10 avr. 2010 à 12:36, chrysanthe m a écrit :
> 
>> Hi, again
>> Sorry for being obtuse.  But can someone help me and even understand how to 
>> write a function and call it on a hash that will take a value, compare it 
>> against each of the keys in the hash, on match delete the key/value, and 
>> return the hash.  tia.
>> 
>> On Thu, Apr 8, 2010 at 5:24 PM, chrysanthe m <chrysant...@gmail.com> wrote:
>> Hi Alex
>> Thanks, but a newbie here so that was "drinking at a firehose".  Let me 
>> parse it to better understand.
>> First can you really invoke on two separate enumerable objects with that 
>> [n,n1,n2] syntax?  That is tremendous.
>> My problem is I need to first check the presence of a key before I unset it 
>> b/c I found out unset-ing a non-existent key seems to zero the struct; also 
>> it is more courteous, grin.  So how would I construct the and parameterize 
>> the annonymous function to do the check and if present "do it to itself".  
>> Ideally I would like to pass in the enumerable, call the function and return 
>> the modified(or not) enumerable in the function's return.  
>> 
>> On Thu, Apr 8, 2010 at 4:41 PM, Alex Wallace <alexmlwall...@gmail.com> wrote:
>> 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 <chrysant...@gmail.com> 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 <chrysant...@gmail.com> 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 
>> prototype-scriptacul...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> prototype-scriptaculous+unsubscr...@googlegroups.com.
>> 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 
>> prototype-scriptacul...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> prototype-scriptaculous+unsubscr...@googlegroups.com.
>> 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 
>> prototype-scriptacul...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> prototype-scriptaculous+unsubscr...@googlegroups.com.
>> 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 prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to 
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> 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 prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to 
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> 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 prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to