Skip to content

Instantly share code, notes, and snippets.

@zeeshankhan
Created April 13, 2016 05:33
Show Gist options
  • Save zeeshankhan/92660a854f7933bd70a410444cd74032 to your computer and use it in GitHub Desktop.
Save zeeshankhan/92660a854f7933bd70a410444cd74032 to your computer and use it in GitHub Desktop.
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