Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Computed Property In Extension Swift

class Circle {
  var radius: Double = 0
}

extension Circle {
  // define computed property 
  var area: Double {
    return 3.14 * radius * radius
  }
}

let circle1 = Circle()
circle1.radius = 5
print("Area:", circle1.area)
 
PREVIOUS NEXT
Tagged: #Computed #Property #In #Extension #Swift
ADD COMMENT
Topic
Name
3+6 =