Skip to content

Instantly share code, notes, and snippets.

@retronym
Last active March 10, 2020 13:56
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 retronym/50839a051db9b6d1fcd0719d99ecbfc2 to your computer and use it in GitHub Desktop.
Save retronym/50839a051db9b6d1fcd0719d99ecbfc2 to your computer and use it in GitHub Desktop.
import scala.concurrent._, duration.Duration, ExecutionContext.Implicits.global
import scala.async.Async.{async, await}
object Test {
def test: Future[Int] = async {
val x: Option[Either[Object, (String, String)]] = Some(Right(("a", "b")))
x match {
case Some(Left(_)) => 1
case Some(Right(("a", "c"))) => 2
case Some(Right(("a", "e"))) => 3
case Some(Right(("a", x))) if "ab".isEmpty => 4
case Some(Right(("a", "b"))) => await(f(5))
case Some(Right((y, x))) if x == y => 6
case Some(Right((_, _))) => await(f(7))
case None => 8
}
}
def f(x: Int): Future[Int] = Future.successful(x)
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkeskells
Copy link

Lost nearly 💯 states !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment