- iOS 12 Programming for Beginners
- Craig Clayton
- 156字
- 2021-07-02 15:04:53
String interpolation
To correct this, we can put these variables inside quotes, which is known as string interpolation, using a backslash and parentheses around each of our variables inside the string interpolation. Let's update our name variable to the following, and you will see the space in the name in the Results Panel:
let full = "\(firstName) \(lastName)"
After adding the preceding line, our code should look something like this:

Now that we know about using variables inside quotes, we can do the same inside print(). Let's put the firstName and lastName variables inside print(), as follows:
print("\(firstName) \(lastName)")
The print statements are great for checking to see whether you are getting the value you want:

Bam! Now, we have a way to view multiple variables inside of print() and to create string interpolation by combining multiple strings. We can do much more with Strings, and we will cover that later in this book.
- 光網(wǎng)絡(luò)評(píng)估及案例分析
- 物聯(lián)網(wǎng)+BIM:構(gòu)建數(shù)字孿生的未來(lái)
- 局域網(wǎng)組建、管理與維護(hù)項(xiàng)目教程(Windows Server 2003)
- React:Cross-Platform Application Development with React Native
- Learning Swift(Second Edition)
- 城市治理一網(wǎng)統(tǒng)管
- Spring 5.0 Projects
- OMNeT++與網(wǎng)絡(luò)仿真
- 網(wǎng)管工具使用與技巧大全
- 網(wǎng)絡(luò)設(shè)計(jì)與應(yīng)用(第2版)
- bash網(wǎng)絡(luò)安全運(yùn)維
- 走近2050:注意力、互聯(lián)網(wǎng)與人工智能
- 互聯(lián)網(wǎng)安全的40個(gè)智慧洞見(2018)
- ElasticSearch Server
- 巧學(xué)活用CISCO網(wǎng)絡(luò)典型配置