What does the type ((Int) -> Int) mean in Swift?

后端 未结 3 1488
悲哀的现实
悲哀的现实 2021-01-12 07:01

I was going through Apple\'s introduction to Swift and came across such example:

func makeIncrementer() -> ((Int) -> Int) {

    func addOne(number: In         


        
3条回答
  •  半阙折子戏
    2021-01-12 07:57

    It indicates that the function returns a function and that returned function takes an Int as an input parameter and returns an Int as well.

    Defining functions within functions is perfectly legal in Swift.

提交回复
热议问题