Created
May 16, 2020 19:58
-
-
Save lu4nm3/b5a63a72a59d6a67e79eddf50a7f8c48 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 Item { | |
implicit val price: Price[Item] = new Price[Item] { | |
def price(item: Item): Double = item match { | |
case cake: Cake => Cake.price.price(cake) | |
case baguette: Baguette => Baguette.price.price(baguette) | |
case apple: Apple => Apple.price.price(apple) | |
case orange: Orange => Orange.price.price(orange) | |
case shampoo: Shampoo => Shampoo.price.price(shampoo) | |
case toothPaste: ToothPaste => ToothPaste.price.price(toothPaste) | |
} | |
} | |
} | |
object Fruit { | |
implicit val price: Price[Fruit] = new Price[Fruit] { | |
def price(fruit: Fruit): Double = fruit match { | |
case apple: Apple => Apple.price.price(apple) | |
case orange: Orange => Orange.price.price(orange) | |
} | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment