Copy-On-Write(COW)

<p>A couple of years ago, during an interview, I was asked a question related to Copy-On-Write (COW). The interviewer asked:</p> <p>&ldquo;Are collections value or reference types in Swift? What should happen when you&rsquo;re creating and assigning an array to another variable?&rdquo;</p> <p>I answered the second question incorrectly. Let&rsquo;s delve into what&rsquo;s happening here and why. In Swift, collections have value semantics. This means that when you create an Array, Dictionary, String, or any other collection in Swift, it&rsquo;s a value type. For example, consider the code below:</p> <p><a href="https://medium.com/@tigran.gishian/copy-on-write-cow-217d2a5148c9"><strong>Read More</strong></a></p>
Tags: COW