I have a lazy variable that is not initialised:
lazy var time: () -> String = {
return String(describing: Date())
}
Whenever I call time() I get a new Date. So it seems like it behaves exactly like:
var time: () -> String {
return {
return String(describing: Date())
}
}
In this context, is it bad practice just to use the lazy closure, because then I don't have to write two return-statements in a row or do I miss something?
lazy var timeis initialized only once – to a closure that, when called, returns a string with the current date.func time() -> String { return String(describing: Date()) }?