Skip to content

Commit 7385a84

Browse files
committed
Fix scaladoc of Try#failed
The documentation stated that it returns a Success[Throwable] regardless, either containing the failure or an UnsupportedOperationException. However only Failure#failed returns a success; Success#failed returns a Failure. Also the phrasing of "Completes this `Try`" and "that `Try` failed with" sounds like it was copy-pasted from Future? Trys don't complete, nor fail, they are immutable.
1 parent d030172 commit 7385a84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/library/scala/util/Try.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ sealed abstract class Try[+T] {
164164
def flatten[U](implicit ev: T <:< Try[U]): Try[U]
165165

166166
/**
167-
* Completes this `Try` with an exception wrapped in a `Success`. The exception is either the exception that the
168-
* `Try` failed with (if a `Failure`) or an `UnsupportedOperationException`.
167+
* Inverts this `Try`. If this is a `Failure`, returns its exception wrapped in a `Success`.
168+
* If this is a `Success`, returns a `Failure` containing an `UnsupportedOperationException`.
169169
*/
170170
def failed: Try[Throwable]
171171

0 commit comments

Comments
 (0)