def doSomething(value) if (value.is_a?(Integer)) print value * 2 else print \"Error: Expected integer value\" exit end end
I would suggest a raise unless type match at the beginning of the method
def do_something(value) raise TypeError, 'do_something expects an integer' unless value.kind_of?(Integer) ... end
This is raise an error and exit unless value is an Integer
Integer