zeeshankhan
4/13/2016 - 5:33 AM

Closures Example

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") }