The goal is to design a generic version for the already present Vector3.WithFoo methods. These do not add any real benefit, however they do provide alternatives to the developer to maximize expressability:
// -- before
Vector3 target;
transform.position = target.WithY(transform.position.y);
// -- after
Vector3 target;
transform.position = transform.position.With(x: target.x, z: target.z);
While the benefits for vectors are marginal, the whole thing becomes much better with colors:
// -- before (other planned feature)
Color color = Color.red;
material.color = color.WithG(0.5f).WithA(0.5f);
// -- after
Color color = Color.red;
material.color = color.With(g: 0.5f, a: 0.5f);
The goal is to design a generic version for the already present
Vector3.WithFoo
methods. These do not add any real benefit, however they do provide alternatives to the developer to maximize expressability:While the benefits for vectors are marginal, the whole thing becomes much better with colors: