back

by epaga·9y ago·view on hn ↗
This is something Swift handles well - computed properties, even if they only have getters, are only allowed to be "var"s, not "let"s (Swift's equivalent to Kotlin's "val").

Looking over the "Learn Kotlin in X minutes" which was posted on HN a few days ago, I was amazed to see how similar Kotlin is to Swift - but this is one difference at least.

1 comments
More importantly, Swift's structs come close to full immutability. If you declare a struct instance with `let`, the compiler throws an error if you try mutating its properties. You also have to mark functions in the struct as mutating if they modify any property. The only case this isn't true (and why I said comes close) is if you modify a property of a reference type within a struct.