Skip to content

Instantly share code, notes, and snippets.

@AkkeyLab
Created November 30, 2019 18:22
Show Gist options
  • Save AkkeyLab/dfba9e607ce1d5c1fd7a1fae6b76776a to your computer and use it in GitHub Desktop.
Save AkkeyLab/dfba9e607ce1d5c1fd7a1fae6b76776a to your computer and use it in GitHub Desktop.
Static value access sample code
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