4 ms·
one thing though, in swift you can actually mutate fields using optional chaining, e.g. person?.name = "Bob". you can't do that in c#. not sure about rust but i
by dotuser 8y ago
one thing though, in swift you can actually mutate fields using optional chaining, e.g. person?.name = "Bob". you can't do that in c#. not sure about rust but in scala you would unwrap the optional with a foreach or something.
- rhodysurf 8y agoYeah and using optionals in rust vs swift makes rust super annoying to use because of that.
- zmmmmm 8y agoIn Groovy you can mutate through optional (null-safe) chaining, eg: x = [ foo: [ bar: 1] ] x.foo.bar // 1 x.boo?.bar // null because x.boo is null x.boo?.bar = 1 // succeeds even though x.boo is null x.boo // still null
- dotuser 8y agoI knew I had seen this somewhere else. I don't understand why C# doesn't support this since most C# code is mutable anyway. I can see why it doesn't fit well with functional languages but C# usually espouses pragmatism over purity and having this would clean up a lot boilerplate null checking.