For example, if you try to output such a simple calculation result (@x below), if nil is included, you should get some error.
a = 1 b = nil @x = a + b
Use the .to_i method. to_i is a method that converts a string to an integer (if it can be recognized as an integer). If it is not recognized as an integer, it returns 0.
Even in the case of nil, since the integer is not recognized, 0 is returned and no error is issued.
If you want to output @x above,
It's OK if you write!