#zettelkasten for #swiftlang programmers -- this is a note from 2016 about copy-on-write in Swift, and it has an incomplete Swift 3 example. Swift 3→4 was a painful migration, but we're at Swift 6 now! So time to select that code and press 'delete' and replace it with something better.
The SharedBuffer example in https://livsycode.com/swift/copy-on-write-in-swift-semantics-misconceptions-and-a-custom-implementation/ is a great template to learn from, for example!
Copy-On-Write in Swift: Semantics, Misconceptions, and a Custom Implementation → Livsy Code

Greetings, traveler! Swift developers encounter copy-on-write (COW) early when working with collections such as Array or String. These types behave like value types while internally sharing storage between copies. The technique allows Swift to preserve value semantics while reducing unnecessary memory duplication. Understanding how this mechanism works provides practical benefits. It clarifies how Swift collections

Livsy Code → Learn Swift the smart way