Skip to content

Instantly share code, notes, and snippets.

@Haaroon
Created August 13, 2021 11:42
Show Gist options
  • Save Haaroon/f18108c20445f4d02e4e7211f4a841f2 to your computer and use it in GitHub Desktop.
Save Haaroon/f18108c20445f4d02e4e7211f4a841f2 to your computer and use it in GitHub Desktop.
Scala Future coffee code from Neophyte
def prepareCappuccino(): Future[Cappuccino] = {
val groundCoffee = grind("arabica beans")
val heatedWater = heatWater(Water(20))
val frothedMilk = frothMilk("milk")
for {
ground <- groundCoffee
water <- heatedWater
foam <- frothedMilk
espresso <- brew(ground, water)
} yield combine(espresso, foam)
}
// part 8 https://danielwestheide.com/blog/the-neophytes-guide-to-scala-part-8-welcome-to-the-future/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment