package eu.xeppaka.scalalearn

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._

object Main3 {
  def checkValue(value: String): Future[Option[Boolean]] = {
    Future {
      if (value == "true") Some(true) else Some(false)
    }
  }

  def main(args: Array[String]): Unit = {
    val f = checkValue("test")
      .map(b => b.map(!_))
      .map(_.map(b =>
        if (!b) {
          b
        } else {
          throw new IllegalArgumentException()
        }
      ).getOrElse(throw new IllegalStateException())
      )

    Await.ready(f, 1.second)
    println(f)
  }
}
