This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class VideoPlayer: Player { | |
| var file: String | |
| var width: Int | |
| var height: Int | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // PUT code into playground | |
| var globalVariable = "globalString" | |
| func fly() { | |
| var localVariable = "localString" | |
| } | |
| struct Airplane { | |
| // Local Variable | |
| var number: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct PropertyStructM { | |
| static func typeMethod() { | |
| // Code | |
| } | |
| } | |
| PropertyStructM.typeMethod() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct NameComponents { | |
| var firstName: String | |
| var lastName: String | |
| mutating func change(firstName: String, lastName: String) { | |
| self.firstName = firstName | |
| self.lastName = lastName | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Player { | |
| var playing: Bool = false | |
| func play() { | |
| playing = true | |
| } | |
| func stop() { | |
| playing = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct PropertyStruct { | |
| static var storedTypeProperty = "1" | |
| static var computedTypeProperty: Double { | |
| return 10.0 | |
| } | |
| } | |
| print("struct type property: \(PropertyStruct.storedTypeProperty)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Pin { | |
| var value: String { | |
| willSet { | |
| print("new pin value: \(newValue)") | |
| } | |
| didSet { | |
| print("old pint value: \(oldValue)") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Payment { | |
| var amount: Float | |
| var comission: Float | |
| var totalAmount: Float { | |
| return amount + comission | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIView { | |
| var cornerRadius: CGFloat { | |
| set { | |
| layer.cornerRadius = newValue | |
| } | |
| get { | |
| return layer.cornerRadius | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EpayBillingProcessor { | |
| var view: UIView? | |
| private lazy var innerView: UIView? = { [unowned self] in | |
| guard let `view` = view else { | |
| return UIView(frame: .zero) | |
| } | |
| return view | |
| }() | |