Afficher un message
Vieux 30/03/2008, 20h28   #4
Rick DeNatale
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ruby 1.9 named arguments

On Sun, Mar 30, 2008 at 2:20 PM, bparanj@gmail.com <bparanj@gmail.com> wrote:
> When I run the following in the irb session, I am getting an error.
> Any ideas why? TIA.
> irb(main):036:0> { :a => 1, :b => 4 }
> => {:a=>1, :b=>4}
> irb(main):037:0> { :x 2, :y 6 }
> SyntaxError: (irb):37: syntax error, unexpected tINTEGER, expecting
> tASSOC
> { :x 2, :y 6 }
> ^


Is this what you were trying to do?

$ irb1.9
irb(main):001:0> {x: 2, y: 6}
=> {:x=>2, :y=>6}


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

  Réponse avec citation
 
Page generated in 0,04465 seconds with 9 queries