📅  最后修改于: 2022-03-11 15:04:46.529000             🧑  作者: Mango
# raise ArgumentError, 'Put error message here' unless some_condition
# example from source link
def inverse(x)
raise ArgumentError, 'Argument is not numeric' unless x.is_a? Numeric
1.0 / x
end
puts inverse(2) # 0.5
puts inverse('not a number') # ArgumentError