Skip to content

Instantly share code, notes, and snippets.

@lu4nm3
Created May 16, 2020 20:00
Show Gist options
  • Save lu4nm3/98e435856854fcc28e63f5d503ff33bc to your computer and use it in GitHub Desktop.
Save lu4nm3/98e435856854fcc28e63f5d503ff33bc to your computer and use it in GitHub Desktop.
def orderTotal(shoppingCart: List[Item]): Double = {
import PriceCompanion._
shoppingCart.foldLeft(0.0) { case (total, item) =>
total + implicitly[Price[Item]].price(item)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment