O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 data) and limitations (what it cannot do with 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 str’s value. Let’s append an exclamation point to the end of the string to make it a well-punctuated sentence. (Whenever new code is added ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required