Class

sclib.ops.try

TryOps

Related Doc: package try

Permalink

implicit class TryOps[A] extends AnyRef

extensions on Try instances

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TryOps
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TryOps(t: Try[A])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def flatMapO(f: (Throwable) ⇒ Try[A]): Try[A]

    Permalink

    apply the given function if it's a failure

    apply the given function if it's a failure

    (read as flatMap other)

    Example:
    1. scala> import sclib.ops.`try`._
      scala> import scala.util.Try
      scala> Try(1/0)
      res0: Try[Int] = Failure(java.lang.ArithmeticException: / by zero)
      scala> Try(1/0).flatMapO(_ => "unable to calculate: 1/0".failure)
      res1: Try[Int] = Failure(java.lang.Exception: unable to calculate: 1/0)
      scala> Try(1/0).flatMapO(_ => 0.success)
      res2: Try[Int] = Success(0)
  10. def fold[B](ff: (Throwable) ⇒ B)(sf: (A) ⇒ B): B

    Permalink

    applies ff if this is a Failure or sf if this is a Success.

    applies ff if this is a Failure or sf if this is a Success.

    Example:
    1. scala> import sclib.ops.`try`._
      scala> "".failure.fold(_.getMessage)(identity)
      res0: String = <ERROR>
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. def mapO(f: (Throwable) ⇒ Throwable): Try[A]

    Permalink

    apply the given function if it's a failure

    apply the given function if it's a failure

    (read as map other)

    Example:
    1. scala> import sclib.ops.`try`._
      scala> import scala.util.Try
      scala> Try(1/0)
      res0: Try[Int] = Failure(java.lang.ArithmeticException: / by zero)
      scala> Try(1/0).mapO(_ => new java.lang.Exception("unable to calculate: 1/0"))
      res1: Try[Int] = Failure(java.lang.Exception: unable to calculate: 1/0)
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  19. def toEither: Either[Throwable, A]

    Permalink

    converts a 'Try[A]' to a 'Either[Throwable, A]'

  20. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. def zip[B](other: Try[B]): Try[(A, B)]

    Permalink

    zip two Try's

    zip two Try's

    returns a Failure if any of the given Trys are a Failure

    Example:
    1. scala> import sclib.ops.`try`._
      scala> import scala.util.Try
      scala> val z = 5.success.zip(11.success)
      res0: Try[(Int, Int)] = Success(5, 11)
      scala> z.map(Function.tupled(_ + _))
      res1: Try[Int] = Success(16)

Inherited from AnyRef

Inherited from Any

Ungrouped