Fixed values
Give a fixed value a name and reuse it wherever the same amount is needed.
Simple example
Use the same factor twice.
Start3 × 2
Result6
def main() raises:
comptime factor = 3
print(factor * 2)
6
Advertisements
Everyday examples
Each bus ticket costs 4 coins. What do three tickets cost?
Start4 × 3
Result12
def main() raises:
comptime fare = 4
print(fare * 3)
12