​Quick is just a strong and instinctive programming language for macOS, iOS, watchOS and tvOS....

Page 181

Swift otherwise it will return some user defined print message by checking the statement 'if circname.print?.circleprint() != nil'.

Accessing Subscripts through Optional Chaining Optional chaining is used to set and retrieve a subscript value to validate whether call to that subscript returns a value. '?' is placed before the subscript braces to access the optional value on the particular subscript.

Program 1 class rectangle { var print: circle? }

class circle { var area = [radius]() var cprint: Int { return area.count }

subscript(i: Int) -> radius { get { return area[i] }

set { area[i] = newValue } } func circleprint() { println("The number of rooms is \(cprint)") } var rectarea: circumference? }

class radius { let radiusname: String

169


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.