簡體   English   中英

Swift Playground 編譯器錯誤:編譯器無法在合理的時間內對該表達式進行類型檢查;

[英]Swift Playground Compiler Error: The compiler is unable to type-check this expression in reasonable time;

當我編寫在 SwiftPlayground 上運行的代碼時,出現了以下編譯錯誤:“編譯器無法在合理的時間內對該表達式進行類型檢查”

public func toPlaygroundValue() -> PlaygroundValue {
    let dict: [:] = [
        "pitch": .floatingPoint(Double(pitch)),
        "roll":  .floatingPoint(Double(roll)),
        "yaw":   .floatingPoint(Double(yaw)),
        "vgx":   .floatingPoint(Double(vgx)),
        "vgy":   .floatingPoint(Double(vgy)),
        "vgz":   .floatingPoint(Double(vgz)),
        "tof":   .floatingPoint(Double(tof)),
        "h":     .floatingPoint(Double(h)),
        "bat":   .integer(bat),
        "baro":  .floatingPoint(Double(baro)),
        "time":  .floatingPoint(Double(time)),
        "agx":   .floatingPoint(Double(agx)),
        "agy":   .floatingPoint(Double(agy)),
        "agz":   .floatingPoint(Double(agz)),
        "marker": PlaygroundValue.dictionary([
            "id":   .integer(marker.id),
            "x":  .floatingPoint(Double(marker.x)),
            "y":  .floatingPoint(Double(marker.y)),
            "z":   .floatingPoint(Double(marker.z)),
        ]),
        "temp": PlaygroundValue.dictionary([
            "temph":   .integer(temp.temph),
            "templ":   .integer(temp.templ),
        ]),
        "mpry":PlaygroundValue.dictionary([
            "x":  .floatingPoint(Double(mpry.x)),
            "y":  .floatingPoint(Double(mpry.y)),
            "z":   .floatingPoint(Double(mpry.z)),
        ]),
        "sn": .string(sn),
    ]
    let value: PlaygroundValue = PlaygroundValue.dictionary(dict)
    return value
}

為變量指定數據類型可能會有所幫助:使用 let dict: [String: PlaygroundValue] = [...] 而不是 let dict: [:] = [...]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM