Varying Variables and Printing to the Console
String is a type, and we say that the str variable is “an instance of the String type.”
Types describe a particular structure for representing data.
Swift has many types, which you will meet throughout this book.
Each type has specific abilities – what the type can do with that data – and limitations – what it cannot do with the data.
For example, the String type is designed to work with an ordered collection of characters and defines a number of functions to work with that ordered collection of characters.
Recall that str is a variable. That means you can change the variable’s value. Let’s append an exclamation point to the end of the string to make it a well-punctuated sentence. (Whenever ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access