title: How to copy a struct and modify one of its properties at the same time?
body: <p>If I want to represent my view controller's state as a single struct and then implement an undo mechanism, how would I change, say, one property on the struct and, at the same time, get a copy of the the previous state?</p>
  
  <pre><code>struct A {
     let a: Int
     let b: Int
  
     init(a: Int = 2, b: Int = 3) {
        self.a = a
        self.b = b
     }
  }
  
  let state = A()
  </code></pre>
  
  <p>Now I want a copy of <code>state</code> but with b = 4. How can I do this without constructing a new object and having to specify a value for every property?</p>