From: Ryan Davis Date: 2010-09-11T07:30:13+09:00 Subject: Re: problem in hash and symbol On Sep 10, 2010, at 14:19 , Amir Ebrahimifard wrote: > Hi everybody > I have a question about hash and symbol. when I use symbol for key in > hash , it didn't for me. what is the problem ? > > (example : hash = { :odd => [ 1 , 3 , 5 ] , :even => [ 2 , 4 , 6 ] , :7 > => "chance" , "number" => 1 } ) what isn't working for you? the :7 ? that's not valid syntax for ruby symbols. You'll have to use the :"extended symbol" notation: > >> hash = { :odd => [ 1 , 3 , 5 ] , :even => [ 2 , 4 , 6 ] , :"7" => "chance" , "number" => 1 } > => {"number"=>1, :"7"=>"chance", :odd=>[1, 3, 5], :even=>[2, 4, 6]}