You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The solution for Up 2 (Da Streets) didn't quite work for me. Minor note: I'm seeing that the Rectangle case class has "val"'s in the constructor. But as for the error, in Square, redefining width/height as val led to 0.0 results for area and perimeter. Keeping them as def's allowed them to calculate correctly:
@ case class Square(size: Double) extends Rectangular {
val width = size
val height = size
}
defined class Square
@ val sq = Square(3)
sq: Square = Square(3.0)
@ sq.perimeter
res6: Double = 0.0
@ case class Square(size: Double) extends Rectangular {
def width = size
def height = size
}
defined class Square
@ val sq = Square(3)
sq: Square = Square(3.0)
@ sq.perimeter
res9: Double = 12.0
@ sq.area
res10: Double = 9.0
The text was updated successfully, but these errors were encountered:
The solution for Up 2 (Da Streets) didn't quite work for me. Minor note: I'm seeing that the Rectangle case class has "val"'s in the constructor. But as for the error, in Square, redefining width/height as val led to 0.0 results for area and perimeter. Keeping them as def's allowed them to calculate correctly:
The text was updated successfully, but these errors were encountered: