I have a piece of code where I ask the user to input a number as an answer to my question. I can do to_i but tricky/garbage inputs would escape through to
to_i
to
This will do to validate the input:
Integer(gets) rescue nil