1.firstIndex(where)
func firstIndex(where predicate: (Element) throws -> Bool) rethrows -> Int?
let index = songs.firstIndex { (song) -> Bool in
return song.name.hasPrefix("一")
}
2.lastIndex(where)
func lastIndex(where predicate: (Element) throws -> Bool) rethrows -> Int?
let index = songs.lastIndex { (song) -> Bool in
return song.name.hasPrefix("一")
}
3.first (where)
first(where predicate: (Element) throws -> Bool) rethrows -> Element?
let window = NSApplication.shared.windows.first { (window) -> Bool in
return (window.contentViewController?.isKind(of: HomeViewController.classForCoder()))!
}
window?.close()