Tag: 堆栈级别

在Ruby中堆栈级别太深,试图绘制随机卡

我在运行下面的代码时出现“堆栈级太深”的错误。 如果选择的随机卡不在那里,它会选择另一张随机卡。 我想我应该以某种方式处理代码,但我不确定如何。 有什么建议? def hit choice_of_card = rand($deck.length); #choose a random card out of the deck drawn_card = $deck[choice_of_card]; #draw that random card from the deck if drawn_card != 0 #if there is a card there $deck[choice_of_card] = 0; #remove that card from the deck by making the space blank if drawn_card == 11 […]