Q:

swift extension for generics array

I want to return [S:M] type, but the Xcode will alert Single argument function types require parentheses, is there any way to fix this, please help me, thanks  
extension Array {
    func merge<S, M>() where Element == [S:M] -> [S:M] {
        var res: [S:M] = [:]
        forEach { (element) in
            element.forEach({ (obj) in
                res[obj.key] = obj.value
            })
        }
        return res
    }
}

A:

-> [S:M] needs to be put before the where clause.
extension Array {
  func merge <S, M> () -> [S: M] where Element == [S: M] {
    var res: [S: M] = [:]

    self.forEach { element in
      element.forEach { obj in
        res[obj.key] = obj.value
      }
    }

    return res
  }
}

