//
//  ArrayExtensions.swift
//  WWDC
//
//  Created by Guilherme Rambo on 19/04/15.
//  Copyright (c) 2015 Guilherme Rambo. All rights reserved.
//

import Foundation

extension RangeReplaceableCollectionType where Generator.Element: Equatable {
    mutating func remove(object: Generator.Element) {
        guard let index = indexOf(object)
            else { return }

        self.removeAtIndex(index)
    }
}
//
//  ArrayExtensions.swift
//  WWDC
//
//  Created by Guilherme Rambo on 19/04/15.
//  Copyright (c) 2015 Guilherme Rambo. All rights reserved.
//

import Foundation

extension Array {
    mutating func remove<U: Equatable>(object: U) {
        var index: Int?
        for (idx, itemToRemove) in self.enumerate() {
            if let to = itemToRemove as? U {
                if object == to {
                    index = idx
                }
            }
        }
        
        if(index != nil) {
            self.removeAtIndex(index!)
        }
    }
    
    func contains<U: Equatable>(object: U) -> Bool {
        for itemToCompare in self {
            if let to = itemToCompare as? U {
                if object == to {
                    return true
                }
            }
        }
        
        return false
    }
}
--- 
+++ 
@@ -8,31 +8,11 @@
 
 import Foundation
 
-extension Array {
-    mutating func remove<U: Equatable>(object: U) {
-        var index: Int?
-        for (idx, itemToRemove) in self.enumerate() {
-            if let to = itemToRemove as? U {
-                if object == to {
-                    index = idx
-                }
-            }
-        }
-        
-        if(index != nil) {
-            self.removeAtIndex(index!)
-        }
-    }
-    
-    func contains<U: Equatable>(object: U) -> Bool {
-        for itemToCompare in self {
-            if let to = itemToCompare as? U {
-                if object == to {
-                    return true
-                }
-            }
-        }
-        
-        return false
+extension RangeReplaceableCollectionType where Generator.Element: Equatable {
+    mutating func remove(object: Generator.Element) {
+        guard let index = indexOf(object)
+            else { return }
+
+        self.removeAtIndex(index)
     }
 }
Update Array extensions for Swift 2.0.

`contains` is now a part of `Array` by default, so this version isn't
necessary. `remove` is a good addition, but the previous version didn't
type-check the element to remove.
