Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Closures Example
let staionary = ["Black Pen", "Blue Pen", "Red Pen", "Green Pen", "Notebook", "Science Book", "Physics Book", "Maths Book", "CD", "Laptop", "Flopy Disk", "Keyboard", "Mouse", "mac OS", "iOS", "LinuxOS", "AndroidOS", "tvOS", "watchOS", "WindowsOS", "iPad", "iPhone", "iPod"]
let books = staionary.filter { (item: String) -> Bool in
return item.containsString("Book")
}
let pens = staionary.filter { (item) in
return item.containsString("Pen")
}
let os = staionary.filter({ item in item.containsString("OS") })
let ip = staionary.filter({ $0.containsString("iP")})
let pens2 = staionary.filter{ $0.containsString("Pen") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment