Swift
Strings #
Interpolation #
let name = "Robb"
let myString = "My name is \(name)"
Replacement #
str.replacingOccurrences(of: "this", with: "that")
Split #
myString.components(separatedBy: " ")
Includes #
let myString = "something cool"
myString.starts(with: "something")
myString.contains("something")
myString.prefix(2)
myString.suffix(2)
Arrays #
Join #
myArray.joined(separator: ", ")
Filter #
let filtered = myArray.filter { $0.count > 1 }
Iterate #
for element in elements {
print(element)
}
elements.forEach { element in
print(element)
}
Index Exists #
myArray.indices.contains(1)
Length of Array #
myArray.count
Links #