I am new to SWIFT and now on the topic of couriers there is such a question, I understand their advantage and ease of use, but the question is that when, for example, you need to write 3 functions 3 different coolers, you can understand what they are doing only by understanding code ...
After all, we do not give any name to them ... As for me it is not very convenient, sit reading the entire courier to understand what he is doing.
Is there any way to call him?
Example
func filterArray(array: [Int], f: (Int) -> Bool) -> [Int] { var filtered = [Int]() for value in array { if f (value){ filtered.append(valeu) } } return filtered } filterArray(numbers) {$0 % 2 == 0} filterArray(numbers) {$0 % 2 == 1} In this case, I understand that this part of the code is called the {$0 % 2 == 0} clause and it differs from this {$0 % 2 == 1} , but this can only be understood by understanding what they are doing.
It seems to me that if, instead of a kloger, functions are defined, named and passed to a function, it will be clear that we are serving ... And it turns out that the courier is an anonymous function that can be understood only by reading it.