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

instance method NilClass#to_i

to_i -> Integer[permalink][rdoc][edit]

0 を返します。

p nil.to_i #=> 0