3 ms·
You could use an explicit private readonly field and a property getter, or even just a public readonly field. I would argue its only sugar.
by jayd16 6y ago
You could use an explicit private readonly field and a property getter, or even just a public readonly field. I would argue its only sugar.
- ygra 6y agoIt doesn't scale that well, as you need ctor parameters for every property, so API additions may also be breaking changes.
- 9wzYQbTYsAIc 6y agoAre you referring to the init only setters? If so, it isn’t just sugar, they added a new hook for it in the internals, rather than just relabelling a technique to accomplish a similar (but not equal) end.
- merb 6y agowell that would be different to instantiate tough. it would be Class(1, 2, 3) instead of Class { Value1=1, Value2=2, Value3=3, } actually record types are more syntactic sugar around what you said than initonly, which opens up a new way of writing code