​Quick is a effective and intuitive coding language for macOS, iOS, watchOS and tvOS....

Page 179

Swift

} }

let rectname = rectangle()

if let rectarea = rectname.print?.cprint { println("Area of rectangle is \(rectarea)") }

else { println("Rectangle Area is not specified")

} When we run the above program using playground, we get the following result: Rectangle Area is not specified

Calling Methods Through Optional Chaining 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("Area of Circle is: \(cprint)") } 167


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