Your first Swift program
Values, types, and a little output.
Start with a value
Use let for a value you will not reassign, and var when it needs to change. Swift can infer the type from a literal. Prefer let by default; mutability should communicate an actual need.
Make the result visible
print writes a representation of a value to standard output. Interpolate a value inside a string using (...). In the playground, that text appears in the console.
Try a small change
Open the example below. Change the input strings and rerun it. Then create a mutable array using var and append another value. Notice that map creates a new result rather than modifying the input.
Try it yourself
let names = ["swift", "foundation"]
print(names.map { $0.uppercased() })
let input = ["12", "oops", "7"]
print(input.compactMap { Int($0) })Track invalid inputs separately when validation failures matter.