-1
嗨,有人可以向我解釋爲什麼我的注入不在這裏工作?重構ruby代碼注入問題
我在這裏使用注射正確嗎?出於某種原因,一旦這種情況下進場(5日移動通常是在我的遊戲)
def cpu_block_player
winning_combinations = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
executed = 0
winning_combinations.each do |combination|
result_of_combination = ""
result_of_combination = combination.inject("") {|result, element| result + @board[element]}
if result_of_combination == "XXe" || result_of_combination == "eXX" || result_of_combination == "XeX"
executed += 1
puts executed
player_move(@current_turn, result_of_combination.index("e"))
end
break if executed >= 1
end
感謝您的回覆!這裏有很多有用的知識 – JaTo