Swift Tutorial - Tutorialspoint

(backadmin) #1
var rectarea: circumference?
}

class radius {
let radiusname: String
init(radiusname: String) { self.radiusname = radiusname }
}

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 circname.print?.circleprint() != nil {
println("Area of circle is specified)")
} else {
println("Area of circle is not specified")
}

When we run the above program using playground, we get the following result:


Area of circle is not specified

The function circleprint() declared inside the circle() sub class is called by creating an
instance named 'circname'. The function will return a value if it contains some value

Free download pdf