Strings are collections again
About 1 min
Strings are collections again 관련
HACKING WITH SWIFT
What's new in Swift?
Strings are collections again | Changes in Swift 4.0
Strings are collections again
Available from Swift 4.0
This is a small change, but one guaranteed to make a lot of people happy: strings are collections again. This means you can reverse them, loop over them character-by-character, map()
and flatMap()
them, and more. For example:
let quote = "It is a truth universally acknowledged that new Swift versions bring new features."
let reversed = quote.reversed()
for letter in quote {
print(letter)
}
This change was introduced as part of a broad set of amendments called the String Manifesto (apple/swift
).
Other Changes in Swift 4.0
Encoding and decoding data using Codable | Changes in Swift 4.0
Encoding and decoding data using Codable
Multi-line string literals | Changes in Swift 4.0
Multi-line string literals
Improved keypaths for key-value coding | Changes in Swift 4.0
Improved keypaths for key-value coding
Improved dictionary functionality | Changes in Swift 4.0
Improved dictionary functionality
One-sided ranges | Changes in Swift 4.0
One-sided ranges