variables.ion 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. let alpha_numeric_name0 = hello
  2. let _name_with_1_leading_underscore = leading
  3. let __2 = underscores
  4. let ___ = !
  5. echo $alpha_numeric_name0 $_name_with_1_leading_underscore $__2 $___
  6. echo -e "\n\n$alpha_numeric_name0"
  7. echo "variables:"
  8. # ANCHOR: variables
  9. let string_variable = "hello string"
  10. let array_variable = [ hello array ]
  11. echo $string_variable
  12. echo @array_variable
  13. # ANCHOR_END: variables
  14. echo "multiple_assignment:"
  15. # ANCHOR: multiple_assignment
  16. let a b = one two
  17. echo $a
  18. echo $b
  19. let a b = one [two three four]
  20. echo $a
  21. echo @b
  22. # ANCHOR_END: multiple_assignment
  23. echo "type_checked_assignment:"
  24. # ANCHOR: type_checked_assignment
  25. let a:bool = 1
  26. let b:bool = true
  27. let c:bool = n
  28. echo $a $b $c
  29. let fail:bool = ""
  30. let a:str b:[str] c:int d:[float] = one [two three] 4 [5.1 6.2 7.3]
  31. echo $a
  32. echo @b
  33. echo $c
  34. echo @d
  35. # ANCHOR_END: type_checked_assignment
  36. echo "dropping_variables:"
  37. # ANCHOR: dropping_variables
  38. let string = "hello"
  39. drop string
  40. let array = [ hello world ]
  41. drop array
  42. # ANCHOR_END: dropping_variables