On Fri, Sep 10, 2010 at 2:19 PM, Amir Ebrahimifard <amiref / ymail.com> 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 } )
> --
> Posted via http://www.ruby-forum.com/.

Looking at that, you've got two symbols (:odd, :even) used as keys, a
string ("number") used as a key, and a great big honking syntax error
(:7) where a key should be. If you want to use the string "7"
converted to a symbol (whether its as a key or otherwise), the Ruby
syntax for that is :"7", the only symbols that don't need quotes are
ones that would be valid ruby identifiers -- and 7, standing alone, is
an integer, not an identifier.

So the hash {:odd => [1, 3, 5], :even => [2, 4, 6], :"7" => "chance",
"number" => 1} seems to (maybe) be what you're looking for.