|
|
|
|
|
by louthy
3385 days ago
|
|
> here's nothing preventing the method call from mutating it. There is, the class could be immutable. public class Vector
{
public readonly int X;
public readonly int Y;
public Vector(int x, int y)
{
X = x;
Y = y;
}
public Vector With(int? X = null, int? Y = null) =>
new Vector(X ?? this.X, Y ?? this.Y);
}
I believe record-types are proposed for the next release of C#. |
|