I have a simple code block calculating the area and perimeter of a rhombus.
var perimeterOfRhombus: Double {
get {
let twoSides1 = sideLength1 + sideLength1
let twoSides2 = sideLength2 + sideLength2
let finalPerimeter = twoSides1 + twoSides2
return finalPerimeter
} set {
}
}
What I am missing is a section.
I want it to show which sideLength1 and sideLength2 were in the beginning.
I'm not sure what newValue is used for when it doesn't matter.
It works without using set, but I see in the Apple language manual swiftthat are installed and usually go together.
If the set is really not needed in this code, what is it usually used in any case?
source
share