1

I am trying to read nested array as follows but getting an error.

var inputArray = [1,[4,3],6,[5,[1,0]]] 

func nestedArray(inputArray :[Any])
{

}

error: heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional var inputArray = [1,[4,3],6,[5,[1,0]]]

rmaddy
  • 314,917
  • 42
  • 532
  • 579
casillas
  • 16,351
  • 19
  • 115
  • 215

1 Answers1

2

You need

var inputArray:[Any] = [1,[4,3],6,[5,[1,0]]] 

as you specify elements of different types Int , Array and nested Array

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87