 // MARK: Dictionary
 
 extension Dictionary {
-    mutating func extend<S: SequenceType where S.Generator.Element == Generator.Element>(newElements: S) -> [Value] {
+    /// Update the values stored in the dictionary with the given key-value pairs, or, if a key does not exist, add a new entry.
+    public mutating func extend<S: SequenceType where S.Generator.Element == Generator.Element>(newElements: S) -> [Value] {
         return newElements.flatMap { 
             (k, v) in updateValue(v, forKey: k) 
         }
     }
 }
 
+/// Return a new dictionary created by extending the lef-side dictionary with the elements of the right-side dictionary
 public func + <K, V, S: SequenceType where S.Generator.Element == (K, V)>(lhs: [K: V], rhs: S) -> [K: V] {
     var result = lhs
     result.extend(rhs)

            old || predicate(new) 
        }
    }
}

extension CollectionType {

    B.factoryMethod()  // type is inferred as B?
**/

/// Optional cast of `x` as type `V`
public func cast<U, V>(x: U) -> V? {
    return x as? V
}

/// Return all values of `source` that were successfully casted to type `V`
public func castFilter<S: SequenceType, V>(source: S) -> [V] {
    return source.flatMap {
        $0 as? V
    }
}

/// Return the first value of `source` that was successfully casted to type `V`
public func castFirst<S: SequenceType, V>(source: S) -> V? {
    return source.flatMap {
        $0 as? V
    }.first
}

/// Forced cast of `x` as type `V`
public func forcedCast<U, V>(x: U) -> V {
    return x as! V
}
