What is the purpose of the two arrows in the user defined chooseStepFunction() in Swift?

前端 未结 3 544
孤城傲影
孤城傲影 2021-01-12 14:29

What do the double arrows indicate in the return type of the last function here?

Are they used to indicate two different return values?

If so, how do you kno

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 15:23

    The -> (Int) -> Int in

    func chooseStepFunction(backwards: Bool) -> (Int) -> Int{
    return backwards ? stepBackward: stepForward
    }
    

    means that the function returns a function that takes an Int as a parameter, and also returns an Int.

    You can see it as func chooseStepFunction(backwards: Bool) -> [ (Int) -> Int ] {

提交回复
热议问题