3 ms·
Hell, Struct already accepts keyword argument options (keyword_init), they could have just added a new one (immutable: true) IMO ImmutableStruct is exactly as
by corytheboyd 4y ago
Hell, Struct already accepts keyword argument options (keyword_init), they could have just added a new one (immutable: true)
IMO ImmutableStruct is exactly as verbose as BasicObject, something that has been in Ruby for a long time now. ImmutableStruct is a massively better name for this.
- knodi123 4y ago> Struct already accepts keyword argument options (keyword_init), they could have just added a new one (immutable: true) The article explains the reason they didn't do that: Ruby maintainers decided that Struct could not be made to suit the requirements of a value object. The core Struct class is a “somewhat alike” value-object; it is compared by value and is, mutable collection-alike (defines to_a and is Enumerable) dictionary-alike (has [] and .values methods)