3 ms·
> Struct already accepts keyword argument options (keyword_init), they could have just added a new one (immutable: true) The article explains the reason they d
by 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)