Is there a way to work around errors in recursive functions in Ruby?
Say, for example, I have this block:
def countUpTo(current, final)
puts current
return nil if current == final
countUpTo(current+1, final)
end
if I call countUpTo(1, 10000), I get an error message: stack level too deep (SystemStackError).
It seems to break into 8187. Is there some kind of function that I can call saying Ruby to ignore stack sizes or a way to increase the maximum stack size?
source
share