Hi, Has anyone seen any documentation on the Hash Object defined in the prototype library? To be precise the following methods - 1. keys 2. values 3. toQueryString 4. inspect 5. Merge I am trying to play around with them and have come up with the following examples - var h = $H({name: "john doe", email: "john-Ch9RrZxMC0c@public.gmane.org", msg: "say hello to me"}); var h_in = h.inspect(); alert(h_in); //returns #<Hash:{''name'': ''john doe'', ''email'': ''john-Ch9RrZxMC0c@public.gmane.org'', ''msg'': ''say hello to me''}> var qs = h.toQueryString(); alert(qs); //returns john%20doe&email=john%40doe.com&msg=say%20hello%20to%20me var mer = h.merge(h); alert(mer.name); //returns john doe alert(mer.email); //returns john-Ch9RrZxMC0c@public.gmane.org alert(mer.msg); //returns say hello to me var a_keys = h.keys(); alert(a_keys); //returns name, email, msg var a_values = h.values(); alert(a_values); //returns john doe,john-Ch9RrZxMC0c@public.gmane.org,say hello to me I want to know if this is the correct usage and how the merge function really works. Any help would be appreciated. Thanks in advance, Mandy.
Anyone? -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Maninder, Singh Sent: Thursday, December 08, 2005 12:49 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Prototype.js Hash Methods Hi, Has anyone seen any documentation on the Hash Object defined in the prototype library? To be precise the following methods - 1. keys 2. values 3. toQueryString 4. inspect 5. Merge I am trying to play around with them and have come up with the following examples - var h = $H({name: "john doe", email: "john-Ch9RrZxMC0c@public.gmane.org", msg: "say hello to me"}); var h_in = h.inspect(); alert(h_in); //returns #<Hash:{''name'': ''john doe'', ''email'': ''john-Ch9RrZxMC0c@public.gmane.org'', ''msg'': ''say hello to me''}> var qs = h.toQueryString(); alert(qs); //returns john%20doe&email=john%40doe.com&msg=say%20hello%20to%20me var mer = h.merge(h); alert(mer.name); //returns john doe alert(mer.email); //returns john-Ch9RrZxMC0c@public.gmane.org alert(mer.msg); //returns say hello to me var a_keys = h.keys(); alert(a_keys); //returns name, email, msg var a_values = h.values(); alert(a_values); //returns john doe,john-Ch9RrZxMC0c@public.gmane.org,say hello to me I want to know if this is the correct usage and how the merge function really works. Any help would be appreciated. Thanks in advance, Mandy. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Not sure if there are docs anywhere, but all those exxcept inspect make sense to me... 1. keys of the hash 2. values of the hash 3. converts your hash to a query string (just like it says) for use in urls 4. not sure exactly what it''s doing without looking at the code 5. should work like the Merge method in Ruby for a Hash object. Try merging with another hash object that has a name key and a different value than the origianl and also add some new key/values pairs in the new hash, then you should see some more interesting results. On 12/8/05, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> Anyone? > > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of > Maninder, Singh > Sent: Thursday, December 08, 2005 12:49 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Prototype.js Hash Methods > > > Hi, > > Has anyone seen any documentation on the Hash Object defined in the prototype library? > > To be precise the following methods - > > 1. keys > 2. values > 3. toQueryString > 4. inspect > 5. Merge > > I am trying to play around with them and have come up with the following examples - > > var h = $H({name: "john doe", email: "john-Ch9RrZxMC0c@public.gmane.org", msg: "say hello to me"}); > var h_in = h.inspect(); > alert(h_in); > //returns #<Hash:{''name'': ''john doe'', ''email'': ''john-Ch9RrZxMC0c@public.gmane.org'', ''msg'': ''say hello to me''}> > > var qs = h.toQueryString(); > alert(qs); > //returns john%20doe&email=john%40doe.com&msg=say%20hello%20to%20me > > var mer = h.merge(h); > alert(mer.name); > //returns john doe > > alert(mer.email); > //returns john-Ch9RrZxMC0c@public.gmane.org > > alert(mer.msg); > //returns say hello to me > > var a_keys = h.keys(); > alert(a_keys); > //returns name, email, msg > > var a_values = h.values(); > alert(a_values); > //returns john doe,john-Ch9RrZxMC0c@public.gmane.org,say hello to me > > I want to know if this is the correct usage and how the merge function really works. > > Any help would be appreciated. > > Thanks in advance, > Mandy. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >