iOS 12 Programming for Beginners
上QQ阅读APP看书,第一时间看更新

Concatenating strings

String concatenation is the result of combining multiple string literals to form an expression. So, let's create one by first entering two string literals:

Combining these two gives us a string concatenation. We can combine strings by using the + operator, add the following:

let full = firstName + lastName

When you look in the Results Panel, you will notice that there is no space between our first and last names.

Also, if we just put the variables in quotes, they will revert to simple string literals and will no longer be variables.