Heim  >  Fragen und Antworten  >  Hauptteil

objective-c - swift中的map()方法

为什么执行次数是5times而不是4times

天蓬老师天蓬老师2727 Tage vor361

Antworte allen(1)Ich werde antworten

  • PHP中文网

    PHP中文网2017-05-02 09:21:57

    你用的是什么调试工具?我把map的closure改了一下:

    var arr = [1,2,3,4]
    let mapArr = arr.map({
      (i: Int) -> Int in
        print("a")
        return i * 2
    })

    只输出了4个 'a'。
    我的平台是:Swift on Ubuntu。

    Antwort
    0
  • StornierenAntwort