Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.45 KB | None | 0 0
  1. func hasAnyMatches(list: [Int], condition: (Int) -> Bool) -> Bool {
  2.     for item in list {
  3.         if condition(item) {
  4.             return true
  5.         }
  6.     }
  7.     return false
  8. }
  9. func lessThanTen(number: Int) -> Bool {
  10.     return number < 10
  11. }
  12. var numbers = [20, 19, 7, 12]
  13. hasAnyMatches(list: numbers, condition: lessThanTen)
  14.  
  15. Trecho de: Apple Inc. “The Swift Programming Language (Swift 3.0.1).” iBooks. https://itun.es/br/jEUH0.l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement