Variables in SRON

Variable is an alias to the memory address which contains your data.

To declare a variable, you have to specify the type of variable first, then the variable name followed by value.

- Syntax
     datatype variable = value

If you don't know what could be the type of value you are getting then you can use 'Any' keyword, like this:

    Any x = [1,2,3,4,5]

Below is a given code to declare variables:

{
    name : MAIN

    Int a= 10, Any b= [1,2,3,4,5]

    Double x= 12.345, Char y= 'S'

    @ declaring a multiline string...
    String multi_str = "Hello, this is
    Saksham Rapid Object Notation."

    @ it is not neccessary to assign a value
    Int x, Double Y, List lst
}

Variable Naming Rules

Before naming a variable or even a function, you should follow some rules:

  • The name of the variable should not be a keyword.

  • It should start with an alphabet or underscore and should contain only alphabets, underscores, and numbers.

  • It's length must be less than 32.

Last updated