Advertisement
Guest User

function swift 3

a guest
Jan 20th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.35 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.         } else {
  6.             return false
  7.         }
  8.     }
  9.    
  10. }
  11. func lessThanTen(number: Int) -> Bool {
  12.     return number < 10
  13. }
  14. var numbers = [20]
  15. hasAnyMatches(list: numbers, condition: lessThanTen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement