​Quick is just a powerful and instinctive programming language for macOS, iOS, watchOS and tvO...

Page 184

Swift

} else if circumNumber != nil { return circumNumber } else { return nil } } }

let circname = rectangle() circname.print?[0] = radius(radiusname: "Diameter")

let printing = circle() printing.area.append(radius(radiusname: "Units")) printing.area.append(radius(radiusname: "Meter")) circname.print = printing

if let radiusName = circname.print?[0].radiusname { println("Radius is measured in \(radiusName).") } else { println("Radius is not specified.") } When we run the above program using playground, we get the following result: Radius is measured in Units. In the above program, the instance values for the membership function 'radiusName' is specified. Hence program call to the function will now return values.

Accessing Subscripts of Optional Type class rectangle { var print: circle? }

class circle { var area = [radius]() var cprint: Int { 172


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