Skip to content

Commit

Permalink
Merge pull request #10586 from som-snytt/doc/either-filter
Browse files Browse the repository at this point in the history
Highlight Either#toOption for filtering
  • Loading branch information
lrytz committed Oct 30, 2023
2 parents a557e93 + 7f59e85 commit 41b9d37
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/library/scala/util/Either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ package util
* // Similarly, refutable patterns are not supported:
* for (x: Int <- right1) yield x
* // error: value withFilter is not a member of Right[Double,Int]
*
* // To use a filtered value, convert to an Option first,
* // which drops the Left case, as None contains no value:
* for {
* i <- right1.toOption
* if i > 0
* } yield i
*
* }}}
*
* Since `for` comprehensions use `map` and `flatMap`, the types
Expand Down

0 comments on commit 41b9d37

Please sign in to comment.