Assignment of Variables

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:

  1. declare integer variable “num” and assign it the value 1
  2. declare list “nums” and add the value of variable “num” as its first item
  3. declare record “map” and add a key “num” with value of variable “num”
  4. declare “num2” and assign the value of “num”
  5. set value of “num” to 0
  6. declare empty list “nums2” (brackets are mandatory, declaration in separate line before assignment is mandatory)
  7. assign “nums2” by “nums”
  8. set value of item in position “num” of list “nums2” to 10
  9. declare list “secondnums” and assign it by “nums”, thus all items of list “nums” will be added to “secondnums”
  10. remove first item from “secondnums”
  11. declare variable “mapnum” and assign by value of item “num” of record “map” (map.num)
  12. set “map.num” to 2
  13. declare “diff” with value of subtraction of “mapnum” from “map.num”
  14. declare string variable “N” and assign by value of system variable “newline”
  15. print all variables information