5 ms·
These all look great, especially tuple literals. I wonder why they chose to make tuples mutable though. Can anyone answer that question?
by jsmeaton 10y ago
These all look great, especially tuple literals. I wonder why they chose to make tuples mutable though. Can anyone answer that question?
- louthy 10y agoThey're not. The type ValueTuple is a value-type.
- zastrowm 10y agoFrom https://github.com/dotnet/roslyn/issues/347 https://github.com/dotnet/roslyn/issues/347 (Details > Mutability): > Should tuples be mutable or immutable? The nice thing about them being > structs is that the user can choose. If a reference to the tuple is > readonly then the tuple is readonly. > Now a local variable cannot be readonly, unless we adopt #115 (which is > likely), but that isn't too big of a deal, because locals are only used > locally, and so it is easier to stick to an immutable discipline if you > so choose. > If tuples are used as fields, then those fields can be readonly if > desired.