Swift初學有一點難理解的東西,整理了一下,想明白了。

來源:互聯網
上載者:User

標籤:

 
func makeIncrementer() -> (Int -> Int) {     func addOne(number: Int) -> Int {         return 1 + number     }     return addOne } var increment = makeIncrementer() 執行:
increment(7)

解釋 :
increment就是makeIncrementer(),所以就會返回AddOne
然後就相當於AddOne(7),
自然就是執行內層函數了,然後就是返回8.


Swift初學有一點難理解的東西,整理了一下,想明白了。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.