Documentations - SRON
  • SRON's Official Documentation
  • Installation
  • Syntax of SRON
  • Executing a SRON code
  • Keywords in SRON
  • Comments in SRON
  • Datatypes in SRON
  • Variables in SRON
  • Memory Ownership Model
  • Operators in SRON
  • Math block
  • if elif else in SRON
  • Loops in SRON
    • For Loop
    • While Loop
    • Foreach Loop
  • Break & Continue
  • Functions in SRON
    • Print functions
    • User Input Functions
    • Type Conversion functions
    • Type Checking functions
    • Math functions
    • Char Functions
    • String Functions
    • List Functions
    • Miscellaneous functions
  • Return in SRON
  • Command Line Arguments
  • Free
  • Rotate
  • Console
  • Sample codes
  • Coding Convention
  • Frequently Asked Questions
  • Credits
  • Contact
  • Donate
Powered by GitBook
On this page

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

PreviousFreeNextConsole

Last updated 6 months ago