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 must not be a keyword.
Should start with an alphabet or underscore
Should contain only alphabets, underscores, and numbers.
It's length must be less than 32.
Last updated