Skip to content

Instantly share code, notes, and snippets.

@sofoklis
Created April 9, 2021 08:57
Show Gist options
  • Save sofoklis/19afa8f6eb03b329625f2150fe9be168 to your computer and use it in GitHub Desktop.
Save sofoklis/19afa8f6eb03b329625f2150fe9be168 to your computer and use it in GitHub Desktop.
val s = Right(1)
val l = Left("Error")
val seq: Seq[(Int, Either[String, Int])] = Seq((2, s), (3, l))
for {
(id, Right(res)) <- seq
} yield (id, res)
for {
(id, Left(error)) <- seq
} yield (id, error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment