Skip to content

Instantly share code, notes, and snippets.

@rirakkumya
Created April 16, 2012 11:28
Show Gist options
  • Save rirakkumya/2397904 to your computer and use it in GitHub Desktop.
Save rirakkumya/2397904 to your computer and use it in GitHub Desktop.
scala> for{(x,y) <- Right((3,4)).right} yield (x,y)
<console>:10: error: constructor cannot be instantiated to expected type;
found : (T1, T2)
required: Either[Nothing,(Int, Int)]
for{(x,y) <- Right((3,4)).right} yield (x,y)
scala> Right((3,4)).right map {case (x,y) => (x,y)}
res118: Product with Either[Nothing,(Int, Int)] with Serializable = Right((3,4))
@rirakkumya
Copy link
Author

scala> Right((2,3)).right.filter{case (x,y) => true;case _  => false}.get.right.map{case (x,y) => (x,y)}
res5: Product with Either[Nothing,(Int, Int)] with Serializable = Right((2,3))

filterが

Option[Either[Nothing,T]]

じゃなくて

Either.RightProjection[Nothing,T]

を返せばいいのに!

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