Packages and Modules
Import Foundation
An import makes a module's library types and functions available to a Swift file.
Use a library after import
import_foundation.swift
import Foundation
let rawName =
let trimSet = CharacterSet.whitespacesAndNewlines
let normalized = rawName.trimmingCharacters(in: trimSet)
let words = normalized.split(separator: " ")
let title = words.map { word in
word.prefix(1).uppercased() + word.dropFirst()
}.joined(separator: " ")
print(title)
import Foundation
let rawName =
let trimSet = CharacterSet.whitespacesAndNewlines
let normalized = rawName.trimmingCharacters(in: trimSet)
let words = normalized.split(separator: " ")
let title = words.map { word in
word.prefix(1).uppercased() + word.dropFirst()
}.joined(separator: " ")
print(title)
import Foundation
let rawName =
let trimSet = CharacterSet.whitespacesAndNewlines
let normalized = rawName.trimmingCharacters(in: trimSet)
let words = normalized.split(separator: " ")
let title = words.map { word in
word.prefix(1).uppercased() + word.dropFirst()
}.joined(separator: " ")
print(title)
import
Swift files use `import` to name the modules they depend on before using the types or helpers provided by those modules.