//
//  ArrayUtils.swift
//  QuickJump
//
//  Created by Victor Shamanov on 5/29/15.
//  Copyright (c) 2015 Victor Shamanov. All rights reserved.
//

import Foundation

extension Array {
    
    var decomposed: (T, [T])? {
        return isEmpty ? nil : (first!, Array(dropFirst(self)))
    }
    
    func each(@noescape f: T -> Void)  {
        for x in self {
            f(x)
        }
    }
    
    func findFirst(p: T -> Bool) -> T? {
        for x in self {
            if p(x) {
                return x
            }
        }
        
        return nil
    }
    
}

//
//  ArrayUtils.swift
//  QuickJump
//
//  Created by Victor Shamanov on 5/29/15.
//  Copyright (c) 2015 Victor Shamanov. All rights reserved.
//

import Foundation

extension Array {
    
    var decomposed: (T, [T])? {
        return isEmpty ? nil : (first!, Array(dropFirst(self)))
    }
    
    func each(f: T -> Void)  {
        for x in self {
            f(x)
        }
    }
    
    func findFirst(p: T -> Bool) -> T? {
        for x in self {
            if p(x) {
                return x
            }
        }
        
        return nil
    }
    
}

--- 
+++ 
@@ -14,7 +14,7 @@
         return isEmpty ? nil : (first!, Array(dropFirst(self)))
     }
     
-    func each(f: T -> Void)  {
+    func each(@noescape f: T -> Void)  {
         for x in self {
             f(x)
         }
Add @noescape attribute to `each` function's closure
