Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 22, 2020 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/7c6d6387a6b27dfdd52a62c7e6c66af7 to your computer and use it in GitHub Desktop.
Save dkomanov/7c6d6387a6b27dfdd52a62c7e6c66af7 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] BooleanOps1
implicit class FutureOfBooleanExtensions(val future: Future[Boolean]) extends AnyVal {
def &&(other: => Future[Boolean]): Future[Boolean] =
future.flatMap(value => if (!value) Future.successful(false) else other)
def ||(other: => Future[Boolean]): Future[Boolean] =
future.flatMap(value => if (value) Future.successful(true) else other)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment