Bug: LeetCode is unable to compile scala code correctly


  • 0
    N
    import scala.util.Either
    
    
    object Main extends App {
        val eL: Either[String, Int] = Left("string")
        val eR: Either[String, Int] = Right(10)
        
        val op = 
        for {
            a <- eR
            b <- eL
        } yield {
            (a, b)
        }
      println(op)
    }
    

    The above code results in compilation error:

    Error: Line 9: error: value flatMap is not a member of scala.util.Either[String,Int] Line 10: error: value map is not a member of scala.util.Either[String,Int] stdin

    The code works perfectly fine with intellij.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.