前端之家收集整理的这篇文章主要介绍了
swift学习笔记之setter和getter方法,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import Foundation
print("Hello,World!")
struct Point {
var x=0.0,y=0.0
};
struct Size {
var width=0.0,height=0.0
};
struct Rect {
var origin=Point()
var size=Size()
var center:Point{
get{
let x=origin.x+size.width/2
let y=origin.y+size.height/2;
return Point(x: x,y: y)
}
}
func getCenter()->(Double,Double)
{
let x=origin.x+size.width/2
let y=origin.y+size.height/2;
return(x,y)
}
};
原文链接:https://www.f2er.com/swift/323644.html