mardi 5 mai 2020

Scala - How to match multiple condition in if else

I have 3 variables like below, and I want the result as first priority is return x, if x is blank then return y, if x and y both blank then return z.

below is my code, but this is not working.

val x = 1
val y = 2
val z = 3

val result = {
var res = "
if (x == "") y else x
else if (y == "") z
}
For result First priority is to x and if x = "" then y, if y also "" then return z

Please help

Aucun commentaire:

Enregistrer un commentaire