Ruby の再帰関数でのスタック オーバーフロー エラーの回避策はありますか?
たとえば、次のブロックがあるとします。
def countUpTo(current, final)
puts current
return nil if current == final
countUpTo(current+1, final)
end
を呼び出すとcountUpTo(1, 10000)
、エラーが発生します: stack level too deep (SystemStackError)
。
8187 で壊れているようです。Ruby にスタックのサイズを無視するように伝える関数、または最大スタック サイズを増やす方法はありますか?