2 ms·
Integer(nil) will raise a TypeError, as will Integer("4x"), but not Integer("4"), so when you want that behaviour, just use Integer(), or Integer.try_conver()
by vidarh 3y ago
Integer(nil) will raise a TypeError, as will Integer("4x"), but not Integer("4"), so when you want that behaviour, just use Integer(), or Integer.try_conver() if you want it to return nil instead of raising an exception.