immutable-struct icon indicating copy to clipboard operation
immutable-struct copied to clipboard

Defaults on keywords arguments

Open nazamoresco opened this issue 3 years ago • 0 comments

Hey👋 I'm using the gem a lot! Would adding defaults with keyword arguments be something worth doing? It shouldn't be hard, I can open a PR if you are interested.

Right now you can override the getters like this

ImmutableStruct.new(:attribute) do 
  def attribute
     @attribute || default
  end 
end

But it would be less verbose to do:

ImmutableStruct.new(attribute: default)

nazamoresco avatar Nov 28 '22 18:11 nazamoresco