课程: Swift 5 Essential Training

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Understanding strings

Understanding strings

- [Instructor] The string class is going to be a constant building block in any Swift application you put together. So we're going to spend a little time understanding its basic features. And the string is literally a collection of characters strung together that can be manipulated, mutated and accessed in various ways. There are also Unicode compliant in Swift and can handle storing special characters. Now let's run through what we already know. We can create string variables without a value by giving them a name. So I'm going to say activeQuest and the string type annotation. Here activeQuest is declared, but not initialized, meaning that the compiler is going to throw us an error if we try and print it out at this point. Now to get around this when you need to initialize a string variable with some kind of empty value, we can just assign it an open and closed set of quotes. And this is largely a style point, but…

内容