I know a difference between computed property and closure with this link, Difference between closure and Computed property.
We are able to write closure in two ways, see an example,
var computedProperty:String{
return "computedProperty"
}
var clouserFirst = { (name: String) -> String in
return "Hello \(name)"
}
var clouserSecond:String = {
return "Hello clouserSecond"
}()
If I write both closure in my class then,
the second closure is called the first time which explains in above link and after that only return those value.
But the first type of closure is calling when we called this closure and closure are a reference type. see closure in apple document.
I know that computed property is work same like function as not store any value in memory.
So, my question is how memory allocation happens in both ways of closure. Can anyone help me to understand this functionality and difference between this two closures?