Ruby 4.1 リファレンスマニュアル

instance method NilClass#to_i

to_i -> Integer[permalink][rdoc][edit]
() → 0

0 を返します。

p nil.to_i # => 0