Page 124

Swift

} } let NewCounter = Samplepgm() NewCounter.counter = 100 NewCounter.counter = 800 When we run the above program using playground, we get the following result: Total Counter is: 100 Newly Added Counter 100 Total Counter is: 800 Newly Added Counter 700

Local and Global Variables Local and global variable are declared for computing and observing the properties. Local Variables Variables that are defined within function, method, or closure context.

Global Variables a

Variables that are defined outside function, method, closure, or type context.

Used to store and retrieve values.

Used to store and retrieve values.

Stored properties is used to get and set the values.

Stored properties is used to get and set the values.

Computed properties are also used.

Computed properties are also used.

Type Properties Properties are defined in the Type definition section with curly braces {} and scope of the variables are also defined previously. For defining type properties for value types 'static' keyword is used and for class types 'class' keyword is used.

Syntax struct Structname { static var storedTypeProperty = " " static var computedTypeProperty: Int { // return an Int value here } } 112

​Fast is really a strong and intuitive coding language for macOS, iOS, watchOS and tvOS....  

Quick is a effective and instinctive programming language for macOS, iOS, watchOS and tvOS....

Read more
Read more
Similar to
Popular now
Just for you