Strings
String interpolation — \(expression) inside a string literal — was introduced briefly in the variables lesson. Any expression can go inside the parentheses, not just a plain variable name, which is why it's generally clearer than building a string with + concatenation.
let name = "world" let greeting = "Hello, \(name)!" print(greeting) print(greeting.count) print(greeting.uppercased())
Hello, world! 13 HELLO, WORLD!
count gives the number of characters, and uppercased() returns a new, fully capitalized string — String methods in Swift are called the same way as on any other type, since String is a genuine struct, not a special built-in.
Next: structs and classes — Swift's two ways to define a custom type, and the value-versus-reference distinction between them.
Practice exercise
Declare a constant name set to "Swift", then print "Learning Swift today" using string interpolation (don't hand-type the full sentence).