This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Circle(radius: Double) { | |
def area = radius * radius * Math.PI | |
} | |
case class Rectangle(side: Double) { | |
def area = side * side | |
} | |
case class Triangle(base: Double, height: Double) { | |
def area = 0.5d * base * height |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val r = (42, "Hello") | |
val (num, str) = r | |
case class Product(name: String, price: Float) | |
val p = Product("Test", 128.8f) | |
val p2 = p.copy(name = "Another") | |
val p3 = Product("Test", 128.8f) | |
// structural comparision of case classes | |
p == p3 |
NewerOlder