The double splat (**hash) in ruby

class MyClass
  def initialize(**attrs)
    @name = attrs[:name]
    @age = attrs[:age]
  end
end

my_object = MyClass.new(name: "John", age: 25)

Leave a Comment

Your email address will not be published. Required fields are marked *