Dcrielaard
6/9/2019 - 8:10 AM

Variables in Swift

Variables in Swift start with the keyword 'let'.

Names for constants start with a lowercase letter. As in the examples below, they can include a few words, all run together. That’s because Swift will think each word is a different identifier if there’s a space in between.

To make it easier to read identifiers with multiple words, every word after the first word should be capitalized. This way of writing out names is called camel case, because the capital letters in the middle of the name look a bit like the humps of a camel. When you define a constant in Swift, it’s called declaring a constant. So the statement above is known as a declaration. “I declare that the name numberOfDogs has the value 101!”.

The word let is an example of a keyword. Keywords have special meaning in Swift and cannot be used as names. The let keyword is used to declare a constant. Over time, you’ll be introduced to more Swift keywords.