关键字是lazy,只能是var的变量才能懒加载
lazy@H_404_4@ var@H_404_4@ count = 100@H_404_4@
lazy@H_404_4@ var@H_404_4@ count = {
return@H_404_4@ 100@H_404_4@
}()
//闭包中如果是多行代码就要报错:unable to infer complex closure return type
lazy@H_404_4@ var@H_404_4@ count = {
var@H_404_4@ a = 100@H_404_4@
var@H_404_4@ b = 100@H_404_4@
return@H_404_4@ a+b
}()
lazy var@H_404_4@ count@H_404_4@: Int = {
var@H_404_4@ a = 100@H_404_4@
var@H_404_4@ b = 100@H_404_4@
return@H_404_4@ a+b
}()
lazy var@H_404_4@ count = {
var@H_404_4@ a = 100@H_404_4@
var@H_404_4@ b = 100@H_404_4@
return@H_404_4@ a+b
}() as Int
lazy var@H_404_4@ count = {
()@H_404_4@ ->@H_404_4@ Int in@H_404_4@
var@H_404_4@ a = 100@H_404_4@
var@H_404_4@ b = 100@H_404_4@
return@H_404_4@ a+b
}()