split()
in swift 3 is deprecated. What will be alternate for below code:
var fullNameArr = split(str) {$0 == "@"}
let world = "Hello, world!".characters.suffix(6).dropLast()
String(world) // β "world"
Here split, which returns an array of subsequences, is also used for string processing. Itβs defined like that:
extension Collection {
func split(maxSplits: Int = default,
omittingEmptySubsequences: Bool = default,
whereSeparator isSeparator: (Self.Iterator.Element) throws -> Bool) rethrows
-> [AnySequence<Self.Iterator.Element>]
}
For example:
let commaSeparatedArray = "a,b,c".characters.split { $0 == "," }
commaSeparatedArray.map(String.init) // β ["a", "b", "c"]
For more detail in split in swift 3