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

Page 151

Swift

length = breadth * 10 }

init(frombre bre: Double) { length = bre * 30 }

init(_ area: Double) { length = area } }

let rectarea = Rectangle(180.0) println("area is: \(rectarea.length)")

let rearea = Rectangle(370.0) println("area is: \(rearea.length)")

let recarea = Rectangle(110.0) println("area is: \(recarea.length)") When we run the above program using playground, we get the following result: area is: 180.0 area is: 370.0 area is: 110.0

Optional Property Types When the stored property at some instance does not return any value that property is declared with an 'optional' type indicating that 'no value' is returned for that particular type. When the stored property is declared as 'optional' it automatically initializes the value to be 'nil' during initialization itself. struct Rectangle { var length: Double?

init(frombreadth breadth: Double) { 139


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