String
Brief introduction
Strings in string are value types, and when passed, the values are copied, and NSString string passes are references. We can iterate through the string with for:
Copy Code code as follows:
var a:string = "a"
For C in "Hello" {
println (c)
}
You can calculate the number of characters for a string by countelements:
Copy Code code as follows:
Countelements ("1234567")//7
Note, however, that the length of countelements and nsstring is not always exactly the same value, because length takes advantage of the value of the UTF-16 type, not the Unicode character. For example, after emoji expression added, the result of UTF-16 calculation is 2, and the result of Unicode is 1. You can look at the following example:
Copy Code code as follows:
var a = "Hello
The above mentioned is the entire content of this article, I hope you can enjoy.