private let firstVc: HZSViewController = {
let vc = HZSViewController(type: .interaction)
return vc
}()
private let secondVc = HZSViewController(type: .interaction)
the second way is seen easier, what's the different between them?
private let firstVc: HZSViewController = {
let vc = HZSViewController(type: .interaction)
return vc
}()
private let secondVc = HZSViewController(type: .interaction)
the second way is seen easier, what's the different between them?
Both accomplish the same thing. The first is more often used when you want to set a number of properties associated with the object before returning it. This is helpful when you have a certain configuration of the object that you want and want to ensure are set before being able to use the object.
In the second scenario, you are limited to the declared properties; any subsequent property changes you want would need to be declared in the lines of code following.