//更改了self的值
struct Point2 {
var x = 0.0,y = 0.0
mutating func moveByX (deltaX:Double,y deltaY:Double){
self = Point2(x:x+deltaX,y: y+deltaY)
}
}
//更改了self的值
enum TriStateSwitch {
case Off,Low,High
mutating func next(){
switch self {
case .Off:
self = Low
case .Low:
self = High
case .High:
self = Off
}
}
}
var ovenLight = TriStateSwitch.Low
ovenLight.next()
ovenLight.next()
原文链接:https://www.f2er.com/swift/323964.html