After creating a class of Triangle and used a read-only computed property named isEquilateral that will determine if equal like this
class Triangle {
var a: Int
var b: Int
var c: Int
// initialization stuff
var isEquilateral: Bool {
return (sideA, sideB) == (sideB, sideC)
}
}
how can I add an observer to check if the lengths changes, from let's say a different type of triangle? Do I add it inside the computed property (isEquilateral) or outside?
As said in this tutorial:
In your case:
This method works for me few time