|
|
|
|
|
by djur
1291 days ago
|
|
Yeah, I'm happy to see this. Every Ruby shop I've worked for has some kind of hand-rolled immutable struct, possibly in addition to various implementations provided by libraries. The backwards compatibility reasoning for not adding an immutable flag to Struct (my first instinct) makes sense. Struct has always been kind of wonky anyway. Getting both positional and kwargs for free is great. I also appreciate that they kept the implementation minimal for now. The pull request shows a very elegant way of implementing default arguments using only language features, which is a good sign: Measure = Data.define(:amount, :unit) do
def initialize(amount:, unit: '-none-') = super
end
|
|