Math block
To solve a mathematical and logical expression, SRON provides the Math block operators '~{ }~'. All you have to do is to put them on the left and right side of your expression.
- Here is a sample code to add two numbers using '+' operator.
{
name : Main
println(~{ 2+2 }~)
String x = "Hello", String y= " World!"
println(~{ x+y }~)
}
Output:
4 Hello World!
- Here is a sample code to check if two integers are equal or not.
{
name : Main
Int a = 10, Int b = 20
println(~{ a == b }~)
println(~{ a != b }~)
}
Output:
false true
You can use all Arithmetic, logical and comparison operators mentioned here inside Math block.
NOTE: You cannot use assignment operator (=, += ...) inside Math block, otherwise it will throw a compile time error.
Last updated