I can't find the solution to my idea. I get an error. I would like to create a big function that takes an array to change such as [1,2,3,42,342,34,3,3,2,4,5,2,3], a list with proper numbers listToFind = [1,2,3,4], and an internal function. The internal function creates a dictionary with listToFind and returns it to a big function where I want to iterate through the array, checking if the i (value) is in a dictionary.
I'm getting the error:
"Value of type '(Int) -> [Int : Bool]' has no subscripts"
after if someFunc[i] != nil {
func myFuncBig (arrayToChange: [Int], listToTakeToFind: [Int], someFunc: (Int) -> [Int:Bool]) -> [Int] {
    var sortedList = [Int]()
    for i in arrayToChange {
        if someFunc[i] != nil {     
            sortedList.append(i)
        }
    }
    return sortedList
}
func createDict (array: [Int]) -> [Int:Bool] {
    var dictToReturn = [Int: Bool]()
    
    for item in array {
        dictToReturn[item] = true
    }
    return dictToReturn
}
It's not clear how to return a dictionary and find a value by key in it because going through the dictionary like dict[i] works without closures.
 
     
     
    