I have below piece of code, which is printing: Some(600) as output.
Its not understood how the addition is happening inside 'for' loop.
In below, its confusing whats happening inside the code block of 'for' loop and how the variable 'y' is being calculated. Can someone please help?
object TestObject extends App
{
def toInt(s: String): Option[Int] = {
try
{
Some(Integer.parseInt(s.trim))
}
catch
{
case e: Exception => None
}
}
val y = for
{
a <- toInt("100")
b <- toInt("200")
c <- toInt("300")
} yield a + b + c
println(y)
}