diff options
author | Seth Tisue <seth@tisue.net> | 2016-09-28 20:55:33 -0700 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2016-09-28 21:07:29 -0700 |
commit | 3bce35e5ce36ca912762375da27e94275aead023 (patch) | |
tree | 8b36c894efdddadae19e4f4b248b9e9a8177bf0b /src/library/scala/util/Either.scala | |
parent | 5757e047a70504991a176aeb2fd8b829d9e9b093 (diff) | |
download | scala-3bce35e5ce36ca912762375da27e94275aead023.tar.gz scala-3bce35e5ce36ca912762375da27e94275aead023.tar.bz2 scala-3bce35e5ce36ca912762375da27e94275aead023.zip |
don't deprecate Either.left and Either.right yet
for two reasons:
* to facilitate warning-free cross-compilation between Scala 2.11
and 2.12
* because it's not clear that .swap is a good replacement for .left
Either.right seems almost certain to be deprecated in 2.13.
Either.left's future is uncertain; see discussion (and links to
additional discussions) at https://github.com/scala/scala/pull/5135
Diffstat (limited to 'src/library/scala/util/Either.scala')
-rw-r--r-- | src/library/scala/util/Either.scala | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index 169786d31b..c332f18295 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -95,13 +95,15 @@ sealed abstract class Either[+A, +B] extends Product with Serializable { /** * Projects this `Either` as a `Left`. */ - @deprecated("use swap instead", "2.12.0") def left = Either.LeftProjection(this) /** * Projects this `Either` as a `Right`. + * + * Because `Either` is right-biased, this method is not normally needed. + * (It is retained in the API for now for easy cross-compilation between Scala + * 2.11 and 2.12.) */ - @deprecated("Either is now right-biased", "2.12.0") def right = Either.RightProjection(this) /** @@ -245,7 +247,7 @@ sealed abstract class Either[+A, +B] extends Product with Serializable { /** * Returns `true` if `Left` or returns the result of the application of - * the given function to the `Right` value. + * the given predicate to the `Right` value. * * {{{ * Right(12).forall(_ > 10) // true @@ -260,7 +262,7 @@ sealed abstract class Either[+A, +B] extends Product with Serializable { /** * Returns `false` if `Left` or returns the result of the application of - * the given function to the `Right` value. + * the given predicate to the `Right` value. * * {{{ * Right(12).exists(_ > 10) // true @@ -426,7 +428,10 @@ object Either { /** * Projects an `Either` into a `Left`. * - * This allows for-comprehensions over Either instances - for example {{{ + * This allows for-comprehensions over the left side of Either instances, + * reversing Either's usual right-bias. + * + * For example {{{ * for (s <- Left("flower").left) yield s.length // Left(6) * }}} * @@ -472,7 +477,6 @@ object Either { * @author <a href="mailto:research@workingmouse.com">Tony Morris</a>, Workingmouse * @version 1.0, 11/10/2008 */ - @deprecated("use swap instead", "2.12.0") final case class LeftProjection[+A, +B](e: Either[A, B]) { /** * Returns the value from this `Left` or throws `java.util.NoSuchElementException` @@ -624,19 +628,13 @@ object Either { /** * Projects an `Either` into a `Right`. * - * This allows for-comprehensions over Either instances - for example {{{ - * for (s <- Right("flower").right) yield s.length // Right(6) - * }}} - * - * Continuing the analogy with [[scala.Option]], a `RightProjection` declares - * that `Right` should be analogous to `Some` in some code. - * - * Analogous to `LeftProjection`, see example usage in its documentation above. + * Because `Either` is already right-biased, this class is not normally needed. + * (It is retained in the library for now for easy cross-compilation between Scala + * 2.11 and 2.12.) * * @author <a href="mailto:research@workingmouse.com">Tony Morris</a>, Workingmouse * @version 1.0, 11/10/2008 */ - @deprecated("Either is now right-biased", "2.12.0") final case class RightProjection[+A, +B](e: Either[A, B]) { /** |