6 ms·
> Swift use value-types by default with copy-on-write semantics. This isn't true. Copy-on-write semantics are implemented only for arrays, dictionaries, and st
by SneakerXZ 2y ago
> Swift use value-types by default with copy-on-write semantics.
This isn't true. Copy-on-write semantics are implemented only for arrays, dictionaries, and strings. Swift value-types are copied immediately.
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/classesandstructures/#Structures-and-Enumerations-Are-Value-Types https://docs.swift.org/swift-book/documentation/the-swift-pr...
- naman34 2y agoThe documentation uses “copied” for value types that are copy-on-write. The documentation has oversimplified a bunch of the mental model and it causes incorrect understanding. Swift’s documentation is quite bad TBH. The biggest thing that still needs to be improved a lot.