Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 22, 2020 22:00
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/ad015c42c53644a1561861e5237706d0 to your computer and use it in GitHub Desktop.
Save dkomanov/ad015c42c53644a1561861e5237706d0 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] BooleanOps2
implicit class BooleanToFutureExtensions(val v: Boolean) extends AnyVal {
def &&(other: => Future[Boolean]): Future[Boolean] =
if (v) other else Future.successful(false)
def ||(other: => Future[Boolean]): Future[Boolean] =
if (v) Future.successful(true) else other
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment