Variables Introduction
Variables
Variables are containers for storing data values.
Creating Variables
Unv has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
x = 5
y = "John"
print(x)
print(y)
Don't change the type of variable after they have been set.
x = 4 # x is of type int
x = "Sally" # x is now a string
print(x)
# This is bad code - hanging the type of varible is NOT good practice
Casting
If you want to specify the data type of a variable, this can be done with casting.
x = string(3) # x will be '3'
y = number(3) # y will be 3
Single or Double Quotes?
String variables can be declared either by using single or double quotes:
x = "John"
# is the same as
x = 'John'
There's no difference in UNV , unlike other languages.
Yes , They are case-sensitive
Variable names are case-sensitive.
This will create two variables:
a = 4
A = "Sally"
#A will not overwrite a
Supported Runtimes
Check is your flavour of Unv is supported.