The code is just for illustrative purposes, i.e. it is an example not a real code.
I tried this:
val results = for(i <- 1 to 20)
{
val x = i+1
println(x)
yield x
}
and this
val results = for {i <- 1 to 20;
val x = i+1;
println(x)
}
yield x
But none of this works — I need a generator, definition, and a statement — is this possible to do it with yield? If yes, what is the correct syntax?
Hopefully, this will get you started:
which is equivalent to