Created
May 15, 2020 08:28
-
-
Save lu4nm3/b3b0d62ddfe23b7cdc798e99db0ccc80 to your computer and use it in GitHub Desktop.
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
object Cake { | |
implicit val price: Price[Cake] = new Price[Cake] { | |
def price(cake: Cake): Double = cake.price | |
} | |
} | |
object Apple { | |
val PricePerLb: Double = 3.0 | |
implicit val price: Price[Apple] = new Price[Apple] { | |
def price(apple: Apple): Double = PricePerLb * apple.weightLbs | |
} | |
} | |
object Shampoo { | |
implicit val price: Price[Shampoo] = new Price[Shampoo] { | |
def price(shampoo: Shampoo): Double = shampoo.price | |
} | |
} | |
// etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment