Question: Both challanges in swift code please . . . enum ShapeDimensions { / / Square's associated value is the length of one side case Square

Both challanges in swift code please ...
enum ShapeDimensions {
// Square's associated value is the length of one side
case Square(Double)
// Rectangle's associated value defines its width and height
case Rectangle(width: Double, height: Double)
func area()-> Double {
switch self {
case let .Square(side):
return side * side
case let .Rectangle(width: w, height: h):
return w * h
}
}
}
 Both challanges in swift code please ... enum ShapeDimensions { //

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!