Skip to content

Instantly share code, notes, and snippets.

@Francescu
Created September 14, 2017 09:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Francescu/7ffcfe58daa73d608f20b27b9cc3f791 to your computer and use it in GitHub Desktop.
Save Francescu/7ffcfe58daa73d608f20b27b9cc3f791 to your computer and use it in GitHub Desktop.
import UIKit
class Foo {
var bar: Int
init(bar: Int) {
self.bar = bar
}
}
struct K {
static let x = Foo(bar: 1)
}
let y = Foo(bar: 1)
func change(_ foo: Foo, to: Int) {
foo.bar = to
}
change(y, to: 3)
change(K.x, to: 3)
print("y \(y.bar)") // prints y 3
print("K.x \(K.x.bar)") // prints K.x 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment