swift 在swift中实现整数结构

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 在swift中实现整数结构相关的知识,希望对你有一定的参考价值。

struct Integerobj {
    var value:Int
    
    init(val:Int=0) {
        self.value = val
    }
    
    mutating func increment() {
        self.value++
    }
    
    mutating func decrement() {
        self.value--
    }
    
    mutating func add(other:Int) {
        self.value += other
    }
    
    mutating func subtract(other:Int) {
        self.value -= other
    }
}

以上是关于swift 在swift中实现整数结构的主要内容,如果未能解决你的问题,请参考以下文章