@AMomchilov , . (, mapping ) - - , , , self ( self ).
, isOk , mapping [Int : () -> Bool], lazy. isOk mapping, , () -> Bool.
struct Test {
func isOk () -> Bool {
return true
}
lazy var mapping: [Int: () -> Bool] = [
1 : self.isOk
]
mutating func test() -> Bool {
return mapping[1]!()
}
}
, test() mutating - lazy , , .
( ), ( ) . mapping -, test mutating.
struct Test {
func isOk () -> Bool {
return true
}
init() {
mapping[1] = isOk
}
var mapping = [Int: () -> Bool]()
func test() -> Bool {
return mapping[1]!()
}
}
, , , , () -> Bool.