Re: [Proto-Scripty] Re: enumerate hash

2010-04-14 Thread Christophe Decaux
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, c

Re: [Proto-Scripty] Re: enumerate hash

2010-04-14 Thread chrysanthe m
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 u

Re: [Proto-Scripty] Re: enumerate hash

2010-04-12 Thread Christophe Decaux
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

[Proto-Scripty] Re: enumerate hash

2010-04-11 Thread RobG
On Apr 10, 8:36 pm, chrysanthe m wrote: > 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 ha

Re: [Proto-Scripty] Re: enumerate hash

2010-04-10 Thread chrysanthe m
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

Re: [Proto-Scripty] Re: enumerate hash

2010-04-08 Thread chrysanthe m
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

Re: [Proto-Scripty] Re: enumerate hash

2010-04-08 Thread Alex Wallace
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.

[Proto-Scripty] Re: enumerate hash

2010-04-08 Thread chrysanthe m
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 wrote: > > -- You