3 ms·
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.micros
by easton 2y ago
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-reference/operators/with-expression https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
- jinwoo68 2y agoI think C# borrowed this feature from functional languages like Haskell or OCaml.
- SebastianKra 2y agoJS/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-programming-language/methods/#Modifying-Value-Types-from-Within-Instance-Methods https://docs.swift.org/swift-book/documentation/the-swift-pr...