if elif else in SRON
SRON provides if, elif and else attributes to take logical decision based upon certain conditions.
A sample code to check if a number is even or odd.
{
name : Main
Int x = 20
if : {
condition : ${ x % 2 == 0 }
println("Even")
}
else : {
println("Odd")
}
}A sample code to check if a number is divisible by either 2 or 3.
{
name : Main
Int x = 15
if : {
condition :${ x % 2 == 0 }
println("Divisible by 2")
}
elif : {
condition : ${ x % 3 == 0 }
println("Divisible by 3")
}
else : {
println("Not Divisible by both 2 and 3")
}
}Last updated