Function Types in Secret Agent Double-Null0111

In the Introduction to the exercise under the Function Types as Parameter Types section, this example is given:

func apply3(to str: String, function f: (String, Int) -> String) -> String {
  f(str,3)
}
// apply3: ([String], (String, Int) -> String) -> [String]

Are the square brackets correct in this example? I think that means <Array> String, but in both the input and the output the type is just String, unless I’m missing something.

Thanks. Happy to stand corrected or submit a PR if needed.

1 Like

Not the Swift maintainer, but I think you’re reading that correctly and that might be a typo. [String] would indicate an array of strings. Later on, we call apply3 with a function typed as (String, Int) -> String and pass in str. The types are inconsistent if str is an array of strings. Also, all the other String types in the code comments just use String and not [String].