What I want to do is make sure that the arguments satisfy some conditions, if not, errors occur.
like this (let's say I want to make sure n> 0):
def some_method(n)
raise "some error" unless n > 0
...
end
Scala has a method requirethat checks an expression by throwing an IllegalArgumentException if false.
if the ruby โโhas something like that?
I know that ruby โโhas series methods assertin unit test. But I do not think that this is what I want.
EDITED
I just want to know if there are other ways to ensure that the arguments satisfy certain conditions, and not raise. ( requirein Scala is so suitable for this.)
source
share