Is there any way to create a method that accepts arguments only if the argument is either 1,2,3?
Is there any way to restrict the arguments passed to the method? Is there anything like:
def some_method(number: [1,2,3])
No, there is nothing like that.
You can, of course, have
if statements inside your method to check the arguments, and then if you find a problem raise an
raise ArgumentError, "Number must be 1, 2, or 3."