DeepCopy
DeepCopy copied to clipboard
Update immutable object
What I really want is something like F# records. Those a helpful feature called Copy and Update Expressions:
type Person = {
FirstName: string
LastName: string
Email: string
}
let person = { FirstName = "first"; LastName = "last"; Email = "email" }
let updatedEmail = { person with Email = "newEmail" } // Copy and Update Expression
Will be nice to create extension method based on deepcopier that will copy and override values like this:
class Person
{
public string FirstName { get; }
public string LastName { get; }
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
}
var person = new Person("bob", "jonhs");
var person2 = person.Update({ FirstName = "michael" });
var person3 = person.Update(p => p.FirstName, "michael");
That sounds like a pretty cool idea, but it's a bit too out-of-scope for this project. It would be worth forking
It would be nice if something like this did exist. Possibly we could have a second project within this repo which adds that kind of functionality.