}
class circumference {
var circumName: String?
var circumNumber: String?
var circumarea: String?
func buildingIdentifier() - > String? {
if circumName != nil {
return circumName
} else if circumNumber != nil {
return circumNumber
} else {
return nil
}
}
}
let circname = rectangle()
if let radiusName = circname.print?[ 0 ].radiusname {
println("The first room name is \(radiusName).")
} else {
println("Radius is not specified.")
}
When we run the above program using playground, we get the following result:
Radius is not specified.
In the above program, the instance values for the membership function 'radiusName' is
not specified. Hence, the program call to the function will return only else part whereas to
return the values we have to define the values for the particular membership function.
If the retrieving type is already optional, then optional chaining will also return an optional
value. For example if String? Is accessed through optional chaining it will return String?
Value.
class rectangle {
var print: circle?