Reputation: 994
How can I set the second argument in a method with three?
For example:
def method(arg1=5, arg2="something", arg3=12)
end
How would I set the second argument without having to do this:
method(arg1=5, "something_else", arg3=12)
Upvotes: 1
Views: 33
Reputation: 227
Just use named parameters by using ":" instead of "=", you code can be :
def method(arg1: 5, arg2: "something", arg3: 12)
end
then you can call the method by setting the value for the argument you need :
method(arg2: "something_else")
Upvotes: 2