Created
November 30, 2019 18:22
-
-
Save AkkeyLab/dfba9e607ce1d5c1fd7a1fae6b76776a to your computer and use it in GitHub Desktop.
Static value access sample code
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
import UIKit | |
final class AkkeyShared { | |
static let shared = AkkeyShared() | |
private init() {} | |
var num = 2 | |
} | |
final class Akkey { | |
static var result: Int { | |
return AkkeyShared.shared.num | |
} | |
let result: Int | |
init(num: Int) { | |
result = num | |
} | |
} | |
let akkey = Akkey(num: 5) | |
print(akkey.result) // 5 ( call `let result: Int` ) | |
print(Akkey.result) // 2 ( call `static var result` ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment