此代码可以正常工作: -
def rps_tournament_winner(tournament)
if tournament[0][0].kind_of?(String)
puts game_winner tournament
else
for i in 0..tournament.length-1
rps_tournament_winner tournament[i]
end
end
end
但是这段代码给了我以下错误 语法错误,意外的tIDENTIFIER,期待kDO或'{'或'('
def rps_tournament_winner(tournament)
array = []
if tournament[0][0].kind_of?(String)
array << game_winner tournament
else
for i in 0..tournament.length-1
rps_tournament_winner tournament[i]
end
end
end
有人可以解释一下原因吗?
由于
答案 0 :(得分:1)
这是一个解析问题。使用括号来澄清:
array << game_winner(tournament)