Created
April 13, 2016 05:33
-
-
Save zeeshankhan/92660a854f7933bd70a410444cd74032 to your computer and use it in GitHub Desktop.
Closures Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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