我正在尝试使用字符串制作哈希:
hash = eval({"name"=>["name", "changed"], "updated_at"=>[nil, Tue, 31 Dec 2013 09:39:29 EET +02:00]})
但是会出现以下错误:
SyntaxError: (irb):19: syntax error, unexpected tCONSTANT, expecting ']'
..."updated_at"=>[nil, Tue, 31 Dec 2013 09:39:29 EET +02:00]})
... ^
(irb):19: Invalid octal digit
..._at"=>[nil, Tue, 31 Dec 2013 09:39:29 EET +02:00]})
... ^
我该如何处理?谢谢大家。
答案 0 :(得分:2)
将此代码编写为: -
hash = eval({"name"=>["name", "changed"], "updated_at"=>[nil, "Tue, 31 Dec 2013 09:39:29 EET +02:00"]})
或
hash = eval({"name"=>["name", "changed"], "updated_at"=>[nil, Date.today]})