I have a class in Swift:
class myClass {
var theBool : Bool
init(theBool: Bool) {
self.theBool = theBool
}
init() {
self.theBool = false
}
}
Elsewhere in my code, I have this check:
classist = myClass()
if let daBool = someRandomBool {
classist.theBool = daBool
}
I want to know where to insert this check into the Class.
Simple solution: Declare the (required)
init
method with an optional parameter type and perform the check thereor – a bit different but still simpler – with a struct