def doSomething(value) if (value.is_a?(Integer)) print value * 2 else print \"Error: Expected integer value\" exit end end
You can raise an Exception anytime arbitrarily if you deem it necessary.
def doSomething(value) if (value.is_a?(Integer)) print value * 2 else raise "Expected integer value" end end
Whether or not you really want to do this is a separate issue. :)