title: (Swift 3)generic parameter T could not be inferred
body: <p>I am trying to create a function which takes in nested arrays of objects like [1,[2,[3,4],[5,6]]] and return values in single array like this [1,2,3,4,5,6]. I wanted to do it for generic objects so I created a method</p>
  
  <pre><code>func getNestedArray&lt;T&gt;(array:[Any])-&gt;[T]?{
  
      var nestedArray:[T] = []
      for object in array{
  
          if object is [Any]{
          let neededArray = getNestedArray(array: object as! [Any])
          nestedArray.append(contentsOf: neededArray)
          }
          else if object is T{
              nestedArray.append(object as! T)
          }
          else{
           print("send proper array dumbass")
              return nil
          }
      }
      return nestedArray
  }
  </code></pre>
  
  <p>so if the object is of type T I just append it or if it is of type array I am calling that function again and recursively should give me the correct result but I am getting the error at while calling this function. what am i doing wrong? I am just passing 'Any' type object as '[Any]'. Why does it throw this error? </p>