[RUBY] About keyword arguments

How to pass a value to a specific argument without worrying about the order of the arguments ***

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

About keyword arguments
About =
About method.invoke
About Kotlin
Make a note of Ruby keyword arguments
About attr_accessor
About Hinemos
About inheritance
About params
About Docker
About Rails 6
About form_for
About Spring ③
About enum
About polymorphism
About Optional
About hashes
About JitPack
About Dockerfile
About this ()
About devise
About encapsulation
About Docker
About JAVA_HOME
About active_hash
About static
About exceptions
About scope
[Maven] About Maven
About call timing and arguments of addToBackStack method
About characters that are completed in method arguments