-
Notifications
You must be signed in to change notification settings - Fork 1
Variables
Jean Dubois edited this page May 10, 2022
·
21 revisions
-
var identifier = expr
: identifier is now expr -
var identifier = var foo = expr
: identifier and foo are now expr - Reserved variable names :
-
null
(0) -
True
(1) -
False
(0) -
None
(a NoneType instance) -
noug_version
(depending the version, str type).
-
- A variable definition return the expr given so it can be used in mathematicals operations :
1 + (var foo = 2)
retuns 3
You can edit variables by multiple ways:
var a = value
var a += value
var a -= value
var a *= value
var a /= value
var a ^= value
var a //= value
var a %= value
-
var a ||= value
: same asvar a = a or value
-
var a &&= value
: same asvar a = a and value
-
var a ^^^= value
: same asvar a = a xor value
-
var a |= value
: same asvar a = a | value
-
var a &= value
: same asvar a = a & value
-
var a ^^= value
: same asvar a = a ^^ value
-
var a === value
: same asvar a = a == value
-
var a <== value
: same asvar a = a <= value
-
var a <<= value
: same asvar a = a < value
-
var a >== value
: same asvar a = a >= value
-
var a >>= value
: same asvar a = a > value
To access to a variable, you can:
- give the identifier:
foo
(returns the value offoo
) - use the special syntax:
foo ? bar ? a ? b
(returns the value offoo
if it is defined, else the value ofbar
... You can put as much? identifier
as you want.)
If you don't need anymore a variable, you can delete it with the del
keyword.
There is 4 types :
- int (integers)
- float (floats)
- str (strings)
- NoneType (None)
var foo = var bar = 12
while var foo = bar - 1 then var bar = bar - 1
Create a variable a
, the delete it:
nougaro> var a = 1
1
nougaro> del a
But be careful! It can return errors:
nougaro> var a = 1
1
nougaro> del a
nougaro> del a
Traceback (more recent call last) :
In file <stdin>, line 1, in <program> :
del a
^
NotDefinedError : a is not defined.