第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Xcode 7.3已棄用“ ++”和“-”運算符

Xcode 7.3已棄用“ ++”和“-”運算符

子衿沉夜 2019-11-28 09:43:15
我正在查看Xcode 7.3注釋,并且注意到了這個問題。++和-運算符已被棄用有人可以解釋為什么不推薦使用它嗎?我說對了,現(xiàn)在在新版本的Xcode中,您將使用它代替++它x += 1;例:for var index = 0; index < 3; index += 1 {    print("index is \(index)")}
查看完整描述

3 回答

?
白衣染霜花

TA貢獻1796條經(jīng)驗 獲得超10個贊

我意識到,盡管如此,此評論仍未解決問題,可能有人會在尋找一種解決方案,以使這些操作員保持工作狀態(tài),這種解決方案可以在底部找到。?


我個人更喜歡++和--運營商。我不同意它們棘手或難以管理的觀點。一旦開發(fā)人員了解了這些運算符的功能(并且我們正在談?wù)摲浅:唵蔚膬?nèi)容),則代碼應(yīng)該非常清楚。


在解釋為什么不推薦使用運算符時,提到了它們的主要用途是C風(fēng)格的for循環(huán)。我對其他人一無所知,但我個人根本不使用C風(fēng)格的循環(huán),在還有其他地方或情況下,++或--運算符是有用的。


我還要提及的是,它varName++返回一個值,因此可以在returnwhile中使用它,而varName += 1不能在其中使用。


對于任何想讓這些操作員在這里工作的人,解決方案是:


prefix operator ++ {}

postfix operator ++ {}


prefix operator -- {}

postfix operator -- {}



// Increment

prefix func ++(inout x: Int) -> Int {

    x += 1

    return x

}


postfix func ++(inout x: Int) -> Int {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: UInt) -> UInt {

    x += 1

    return x

}


postfix func ++(inout x: UInt) -> UInt {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Int8) -> Int8 {

    x += 1

    return x

}


postfix func ++(inout x: Int8) -> Int8 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: UInt8) -> UInt8 {

    x += 1

    return x

}


postfix func ++(inout x: UInt8) -> UInt8 {

    x += 1

    return (x - 1)

}

prefix func ++(inout x: Int16) -> Int16 {

    x += 1

    return x

}


postfix func ++(inout x: Int16) -> Int16 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: UInt16) -> UInt16 {

    x += 1

    return x

}


postfix func ++(inout x: UInt16) -> UInt16 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Int32) -> Int32 {

    x += 1

    return x

}


postfix func ++(inout x: Int32) -> Int32 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: UInt32) -> UInt32 {

    x += 1

    return x

}


postfix func ++(inout x: UInt32) -> UInt32 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Int64) -> Int64 {

    x += 1

    return x

}


postfix func ++(inout x: Int64) -> Int64 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: UInt64) -> UInt64 {

    x += 1

    return x

}


postfix func ++(inout x: UInt64) -> UInt64 {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Double) -> Double {

    x += 1

    return x

}


postfix func ++(inout x: Double) -> Double {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Float) -> Float {

    x += 1

    return x

}


postfix func ++(inout x: Float) -> Float {

    x += 1

    return (x - 1)

}


prefix func ++(inout x: Float80) -> Float80 {

    x += 1

    return x

}


postfix func ++(inout x: Float80) -> Float80 {

    x += 1

    return (x - 1)

}


prefix func ++<T : _Incrementable>(inout i: T) -> T {

    i = i.successor()

    return i

}


postfix func ++<T : _Incrementable>(inout i: T) -> T {

    let y = i

    i = i.successor()

    return y

}


// Decrement

prefix func --(inout x: Int) -> Int {

    x -= 1

    return x

}


postfix func --(inout x: Int) -> Int {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: UInt) -> UInt {

    x -= 1

    return x

}


postfix func --(inout x: UInt) -> UInt {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Int8) -> Int8 {

    x -= 1

    return x

}


postfix func --(inout x: Int8) -> Int8 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: UInt8) -> UInt8 {

    x -= 1

    return x

}


postfix func --(inout x: UInt8) -> UInt8 {

    x -= 1

    return (x + 1)

}

prefix func --(inout x: Int16) -> Int16 {

    x -= 1

    return x

}


postfix func --(inout x: Int16) -> Int16 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: UInt16) -> UInt16 {

    x -= 1

    return x

}


postfix func --(inout x: UInt16) -> UInt16 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Int32) -> Int32 {

    x -= 1

    return x

}


postfix func --(inout x: Int32) -> Int32 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: UInt32) -> UInt32 {

    x -= 1

    return x

}


postfix func --(inout x: UInt32) -> UInt32 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Int64) -> Int64 {

    x -= 1

    return x

}


postfix func --(inout x: Int64) -> Int64 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: UInt64) -> UInt64 {

    x -= 1

    return x

}


postfix func --(inout x: UInt64) -> UInt64 {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Double) -> Double {

    x -= 1

    return x

}


postfix func --(inout x: Double) -> Double {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Float) -> Float {

    x -= 1

    return x

}


postfix func --(inout x: Float) -> Float {

    x -= 1

    return (x + 1)

}


prefix func --(inout x: Float80) -> Float80 {

    x -= 1

    return x

}


postfix func --(inout x: Float80) -> Float80 {

    x -= 1

    return (x + 1)

}


prefix func --<T : BidirectionalIndexType>(inout i: T) -> T {

    i = i.predecessor()

    return i

}


postfix func --<T : BidirectionalIndexType>(inout i: T) -> T {

    let y = i

    i = i.predecessor()

    return y

}


查看完整回答
反對 回復(fù) 2019-11-28
  • 3 回答
  • 0 關(guān)注
  • 682 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號