Qtr No. 213, New Town Yehlanka Indore 454775
Find the output for the below code
import scala.util.{Try, Success,Failure}
object Main extends App
{
def justTry(n:Int) ={ val tryMap=Map(0->Try(0),1->Try(1), 2->Try(2), 3->Try("3"))
Try(tryMap(n))
}
for(n<-2 to 4)
{
println(justTry(n).filter(y=>y.isFailure==false))
}
}
Success(Success(2))
Success(Success(3))
Success(Success(2))
Success(Success(3))
Failure(java.util.NoSuchElementException: key not found: 4)
Success(Success(2))
Success(Success(3))
Failure
Success(Success(2))}
Success(Success(3))
Success(Success(4))
To get all Infosys Certified Scala Programmer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in