这是我的计划:
my_hash.each |w| do
p "is this right?"
awesome_print w
fix = gets
fix.chop
if (fix == "N")
p "Tell me what it should be"
correction = gets
w[1] = correction
end
end
这是我得到的错误:
what.rb:1: syntax error, unexpected keyword_do_block
what.rb:12: syntax error, unexpected keyword_end, expecting $end
有人知道我为什么会收到这个错误吗?
这是my_hash:
{:banana=>:fruit, :pear=>:fruit, :sandal=>:fruit, :panda=>:fruit, :apple=>:fruit}
我只想以传统的Ruby方式对每个单独的密钥对进行操作。我该怎么做?
答案 0 :(得分:4)
你的语法是向后的。它应该是:
my_hash.each do |w|
而不是:
my_hash.each |w| do