Swift Variables in Real-Life
Swift Variables in Real-Life
Use variables to track values like counters, flags, and user input.
Example: Counter
Use a variable to track a counter and print it as it changes.
Example: Greeting
Store a value in a variable and use interpolation to print it.
Example
var name = "Kai"
print("Hello, \(name)!")
name = "Elisabeth"
print("Hello, \(name)!")
This example updates a variable and prints the new greeting.