ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Nested
    scala/cats2 2023. 1. 16. 10:07

    cats Nested 예제

     

    import cats.data._
    import cats.syntax.all._
    import scala.util.{Success, Try}
    
    object NestedExample {
      def main(args: Array[String]): Unit = {
        val someValue: Try[Option[Int]] = Success(2.some)
    
        val basicScala: Try[Option[Int]] = someValue.map(_.map(_ * 3))
        val catsScala: Try[Option[Int]]  = Nested(someValue).map(_ * 3).value
      }
    }

    'scala > cats2' 카테고리의 다른 글

    Cats2 Exercise  (0) 2023.01.22
    Validated  (0) 2023.01.19
    Writer  (0) 2023.01.19
    OptionT  (0) 2023.01.16
    State  (0) 2023.01.10

    댓글

Designed by Tistory.