Assignment of variables in Till is done in a “by value” mode. Meaning, the target variable is getting the data from the source variable without being attached to it by reference, thus enabling the source to retain its data even if the target changed its data.
Note:
To cover all declaration and assignment scenarios is beyond the scope of this overview and it is recommended to go through all examples in the reference.
Examples:
num 1
nums num
map { num num }
num2 num
num 0
nums2 []
nums2 nums
nums2 num 10
secondnums nums
secondnums ->
mapnum map.num
map.num 2
diff map.num - mapnum
N newline
print 'num ' + num + N + 'num2 ' + num2
print 'nums ' + nums
print 'secondnums ' + secondnums
print 'nums2 ' + nums2
print 'map ' + map
print 'diff ' + diff
num 0
num2 1
nums [ 1 ]
secondnums [ ]
nums2 [ 10 ]
map {
num: 2
}
diff 1
- declare integer variable “num” and assign it the value 1
- declare list “nums” and add the value of variable “num” as its first item
- declare record “map” and add a key “num” with value of variable “num”
- declare “num2” and assign the value of “num”
- set value of “num” to 0
- declare empty list “nums2” (brackets are mandatory, declaration in separate line before assignment is mandatory)
- assign “nums2” by “nums”
- set value of item in position “num” of list “nums2” to 10
- declare list “secondnums” and assign it by “nums”, thus all items of list “nums” will be added to “secondnums”
- remove first item from “secondnums”
- declare variable “mapnum” and assign by value of item “num” of record “map” (map.num)
- set “map.num” to 2
- declare “diff” with value of subtraction of “mapnum” from “map.num”
- declare string variable “N” and assign by value of system variable “newline”
- print all variables information