Skip to content

Instantly share code, notes, and snippets.

@antonio081014
Created September 23, 2016 05:26
Show Gist options
  • Save antonio081014/be743650519f1003cf728adce991cf89 to your computer and use it in GitHub Desktop.
Save antonio081014/be743650519f1003cf728adce991cf89 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground" {
//"Hello, playground"
willSet {
print("willSet \(str) : \(newValue)")
// "willSet Hello, playground : Hello, Antonio.\n"
str = "Hi"
// "Hi"
print("willSet \(str) : \(newValue)")
//"willSet Hi : Hello, Antonio.\n"
}
didSet {
print("didSet \(str) : \(oldValue)")
//"didSet Hello, Antonio. : Hello, playground\n"
str = "Hi"
// "Hi"
print("willSet \(str) : \(oldValue)") //
//"didSet Hi : Hello, playground\n"
}
}
str = "Hello, Antonio."
// "Hello, Antonio."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment