swift - Computed properties cannot store a value but hold a value, what is hold and how to hold? -
quote "swift apprentice second edition page 225":
properties(computed) hold values can , set. methods perform work
quote "swift official document":
in addition stored properties, classes, structures, , enumerations can define computed properties, not store value
one says "store", 1 says "hold". bit confused computed properties, computed properties not store value means? means system not assign memory space save value , hold it. what's hold means? can't hold in nowhere, need maybe box hold something, isn't it?
simple example documentation
struct cuboid { var width = 0.0, height = 0.0, depth = 0.0 var volume: double { return width * height * depth } }
volume
never stored in memory. whenever getter called result of multiplication returned dynamically math operation in local scope.
the official apple documentation not use term hold
@ all.
Comments
Post a Comment