Chris Pine, Ch10, Factorial Method

Hi All,

Two questions:

  1. Is this the best forum to ask beginner questions? I’m learning Ruby
    and I need a support community.

  2. I’m work on the factorial method on page 84 of Pine’s book. Here’s
    the code:

def factorial num
if num < 0
return ‘You can’t take the factorial of a negative number!’
end

if num <= 1
1
else
num * factorial(num-1)
end

end
puts factorial(3)

My question is, why wouldn’t num go below 1 (like 0 or negative
integers) and result in a return of the string ‘You can’t take the…’?

Is something built into Ruby to stop at 0?

Thanks