有人可以解释一下为什么这段代码不起作用吗?我对红宝石还不是很了解,所以希望你能提供帮助。它说我有语法错误puts multi[is]
:
syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '<' puts multi[is]
这是代码:
# multi = Array.new
# multi[0] = Array.new(2, 'hello')
# # multi[1] = Array.new(2, 'world')
# puts(multi[0])
# puts(multi[1])
multi = ['hest','hund','kat','fugl'] # names of animals
for i in multi # convert to
is = i.to_i
is++
# puts(i. inspect
puts multi[is] # her i have error says syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '<' puts
multi[is]
end
food = Array.new # a new arry
# 0 milk names for food
# 1 ost
# 2 kod
# 3 ris