InfySkyWave is working on a Student portal to display the winner for a quiz contest conducted in various batches. Janet is working on the following incomplete code where collections with futures is used to retreive the details in an easier way. (Assume necessary imports have been done.)
object ScalaFutList extends App {
val f: Future[List[String]] = Future {
List("Sharon Levin Leon", "Sneha Sweta Sherin", "John Riya Mega")
}
//Line 1
val result = Await.result(f1, Duration(2, "sec"))
println(result)
}What code should be placed at Line 1 to get the winners as shown below?
List(Sharon, Sneha, John)
val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(0)))
val f1: Future[List[String]] = f.map(x => x.split(" ")(1))
val f1: Future[List[String]] = f.map(x => x(1))
val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(1)))
To get all Infosys Certified Scala Programmer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee