http://blog.csdn.net/lzx_322/article/details/28861199
The SWIFT function uses the previous need to add Func with return values that need to be added back with the return type, it is easy to understand, in the English version of the PDF document when you see the return value of nested functions, at first not too clear, think carefully for a while is still easy to understand:
For example: Func Stepbackward (input:int), Int {
Return input-1
}
The return value is of type int.
Func choosestepfunction (Backwards:bool)-(int)-int {
Func Stepforward (input:int), Int {return input + 1}
Func Stepbackward (input:int), Int {return input-1}
return backwards? Stepbackward:stepforward
}
The Choosestepfunction return value type here is (int), int, and the return in the function is the function stepbackward or stepforward, and the type of the two functions is (int), int. The final value returned is the int type.
Again for example:
Func testfunction (A:int,b:int)-(Int,int)->int{
Func getfunction (a:int,b:int)->int{
Return A-B
}
Return getfunction
}
The outside function returns the (Int,int)->int, which returns the function that nested inside the polygon, which ultimately returns the return value of the nested inside function. This is my understanding of nested return, the expression is not very clear, I hope to be helpful to everyone, the shortcomings of the welcome point.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Swift's nesting understanding func choosestepfunction (backwards:bool), int