Skip to content

Instantly share code, notes, and snippets.

@vigneshwaranr
Created February 14, 2021 07:41
Show Gist options
  • Save vigneshwaranr/031a890f78d3a925e78f4581e33c7430 to your computer and use it in GitHub Desktop.
Save vigneshwaranr/031a890f78d3a925e78f4581e33c7430 to your computer and use it in GitHub Desktop.
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
trait WaterSupply {
def turnOn(): Future[Unit]
}
trait PowerPlant {
def waterSupply: WaterSupply
def increaseVolumeControl(): Future[Boolean]
def turnOn(): Future[Boolean] = {
waterSupply.turnOn().flatMap { _ =>
increaseVolumeControl()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment