Fast is really a strong and instinctive development language for macOS, iOS, watchOS and tvOS....

Page 190

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, the program call to the function will now return values.

Chaining on Methods with Optional Return Values Optional chaining is used to access subclasses defined methods too. class rectangle { var print: circle? }

class circle { var area = [radius]() 178


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