Rotate

If you want to swap two value or wants to rotate value of variables, then this attribute is used.

Syntax:

    rotate : (variable1 , variable2, variable3)

NOTE: 'Rotate' requires only variables, other values cannot be inserted into it.

Examples:

Correct Syntax:
    rotate : (val1 , val2 , val3)
or
    rotate : (val1 , val2)

------------ 

Wrong Syntax:
    @ you need to insert all value within round-brackets
    rotate : val1 , val2
or
    @ rotate requires at least two variables
    rotate : (val1)
or
    @ rotate expects only variables, no 
    @ other type of tokens are allowed
    rotate : (val1, "SRON", val2)

Sample code to swap two variables using 'rotate' attribute

{
    name : Main
    Int val1 = 2706
    Int val2 = 2003

    println("\n Before Swap: A = ", val1, "    B = ", val2)

    rotate : (val1 , val2)

    println("\n After Swap: A = ", val1, "    B = ", val2)
}

OUTPUT:

Before Swap: A = 2706 B = 2003 After Swap: A = 2003 B = 2706


Sample code to rotate values of more than two variables using 'rotate' attribute

{
    name : Main
    Int val1 = 2706
    String val2 = 2003
    Bool val3 = true

    println("\n Before Rotate: A = ", val1, "    B = ", val2, "    C = ", val3)

    rotate : (val1 , val2, val3)

    println("\n After Rotate: A = ", val1, "    B = ", val2, "    C = ", val3)
}

OUTPUT:

Before Swap: A = 2706 B = 2003 C = true After Rotate: A = 2003 B = true C = 2706

Last updated