Suppose you have the following classes and methods.
class Person
def profile(name = 'name', age = 'age')
@name = name
@age = age
end
end
Here, if you do person.profile (age: 30)
, you can pass 30 to age.
Normally, values are passed in order from the first argument, but if you specify the arguments in this way, you can pass the values to the arguments as intended without worrying about the order of the arguments described in the method.
Recommended Posts