Hacker News new | past | comments | ask | show | jobs | submit login

C# has the with part as a language built in; we use it at work with our immutable objects.

    var y = x with { things I want to change }
https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...



JS/TS has

    y = { ...x, change: 'b' }
And Swift avoids the mutability-problem all together, by providing structs with copy-on-write and self-mutating methods:

https://docs.swift.org/swift-book/documentation/the-swift-pr...


I think C# borrowed this feature from functional languages like Haskell or OCaml.


I would credit F# even more. It's been a main source of new C# features for a while now.


From F#, most likely! C# converges more and more on F# with every release.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: