I am having trouble with this question can anybody help me with the solution

Here How to pass argument with function call inside a class and take that argument as parameter from another class function????

First error:

func displayArray expects to return an array [[[Int]]].

So, it tries to interpret print as a return value, which fails.

  • So, add a return statement
return someArray of type [[[Int]]]
  • or more likely, declare func without return value
func displayArray(array1: [[[Int]]] {
  print(array1)
}

Second error:

you try to pass a second argument to displayArray which expects one only. Change as:

outputobj.displayArray(array1: myArray)

Of course, you need a closing parenthesis at the end of arguments list. Sorry for the typo.

func displayArray(array1: [[[Int]]]) {

A good practice here is to declare an alias type

typealias tripleArray = [[[Int]]]
func displayArray(array1: tripleArray) {
}

If you want to return the flat array from the triple array, just use flatMap:

func displayArray(array1: tripleArray) -> [Int]  {

  print(array1)
  return array1.flatMap({ $0 })
}

When you print the value returned, you will get

[2, 4, 6, 4, 6, 7, 1, 9, 3]

I am having trouble with this question can anybody help me with the solution
 
 
Q