Hi Guyz, Problem with me is that whenever i am storing values in my hash.. it stores perfectly .. But when i am trying to print it .. i mean try to view its contents .. then contents coming in wrong order .. which i dont want .. Can sum one help me bit about it .. ? -- Posted via http://www.ruby-forum.com/.
Hashes won''t keep the insertion order in Ruby (or any other language, you''ll usually have to use some kind of ordered hash). - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Wed, Jul 22, 2009 at 9:23 AM, Hemant Bhargava<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi Guyz, > > Problem with me is that whenever i am storing values in my hash.. it > stores perfectly .. > > But when i am trying to print it .. i mean try to view its contents .. > then contents coming in wrong order .. which i dont want .. > > Can sum one help me bit about it .. ? > -- > Posted via http://www.ruby-forum.com/. > > > >
So no solution .. is it .. ? Maurício Linhares wrote:> Hashes won''t keep the insertion order in Ruby (or any other language, > you''ll usually have to use some kind of ordered hash). > > - > Maur�cio Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > > > On Wed, Jul 22, 2009 at 9:23 AM, Hemant-- Posted via http://www.ruby-forum.com/.
But i remember i had done it in Perl .. So y not with ruby .. Hemant Bhargava wrote:> So no solution .. is it .. ? > > > > Maurício Linhares wrote: >> Hashes won''t keep the insertion order in Ruby (or any other language, >> you''ll usually have to use some kind of ordered hash). >> >> - >> Maur�cio Linhares >> http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr >> >> >> >> On Wed, Jul 22, 2009 at 9:23 AM, Hemant-- Posted via http://www.ruby-forum.com/.
http://loopkid.net/articles/2008/06/19/ordered-hashes-in-ruby-1-8 - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Wed, Jul 22, 2009 at 9:29 AM, Hemant Bhargava<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > But i remember i had done it in Perl .. So y not with ruby .. > > Hemant Bhargava wrote: >> So no solution .. is it .. ? >> >> >> >> Maurício Linhares wrote: >>> Hashes won''t keep the insertion order in Ruby (or any other language, >>> you''ll usually have to use some kind of ordered hash). >>> >>> - >>> Maur�cio Linhares >>> http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr >>> >>> >>> >>> On Wed, Jul 22, 2009 at 9:23 AM, Hemant > > -- > Posted via http://www.ruby-forum.com/. > > > >
Hi -- On Wed, 22 Jul 2009, Hemant Bhargava wrote:> So no solution .. is it .. ?Hashes in Ruby 1.9 are ordered by key insertion order. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)
No i dont think so .. The way i am inserting values in hash is not d way i am getting these values .. David A. Black wrote:> Hi -- > > On Wed, 22 Jul 2009, Hemant Bhargava wrote: > >> So no solution .. is it .. ? > > Hashes in Ruby 1.9 are ordered by key insertion order. > > > David > > -- > David A. Black / Ruby Power and Light, LLC > Ruby/Rails consulting & training: http://www.rubypal.com > Now available: The Well-Grounded Rubyist (http://manning.com/black2) > Training! Intro to Ruby, with Black & Kastner, September 14-17 > (More info: http://rubyurl.com/vmzN)-- Posted via http://www.ruby-forum.com/.
2009/7/22 Maurício Linhares <mauricio.linhares-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > Hashes won''t keep the insertion order in Ruby (or any other language, > you''ll usually have to use some kind of ordered hash). > > - > Maurício Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > >This isn''t true because the insertion order is maintained in Ruby 1.9.1 as well as Smalltalk. -Conrad> > > On Wed, Jul 22, 2009 at 9:23 AM, Hemant > Bhargava<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Hi Guyz, > > > > Problem with me is that whenever i am storing values in my hash.. it > > stores perfectly .. > > > > But when i am trying to print it .. i mean try to view its contents .. > > then contents coming in wrong order .. which i dont want .. > > > > Can sum one help me bit about it .. ? > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
By d way champs .. where to write the code for require ''file'' .. ? in layouts file or in same file .. or in controller or in model .. :) Conrad Taylor wrote:> 2009/7/22 Maurício Linhares <mauricio.linhares-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> >> Hashes won''t keep the insertion order in Ruby (or any other language, >> you''ll usually have to use some kind of ordered hash). >> >> - >> Maurício Linhares >> http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr >> >> > This isn''t true because the insertion order is maintained in Ruby 1.9.1 > as well as Smalltalk. > > -Conrad-- Posted via http://www.ruby-forum.com/.
Hi -- On Wed, 22 Jul 2009, Hemant Bhargava wrote:> > David A. Black wrote: >> Hi -- >> >> On Wed, 22 Jul 2009, Hemant Bhargava wrote: >> >>> So no solution .. is it .. ? >> >> Hashes in Ruby 1.9 are ordered by key insertion order. >> > > No i dont think so .. > The way i am inserting values in hash is not d way i am getting these > values ..Then you''re not using Ruby 1.9 :-) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)