swift get,set

前端之家收集整理的这篇文章主要介绍了swift get,set前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//: Playground - noun: a place where people can play


importCocoa




structpoint{

varx=0;

vary=init(x:Int,y:Int){

self.x= x;

y= y;

}

varscale:Int{

get{

returnx/x; }

set{

x*=newValue;

y*=newValue;

}

}

}


varpt =point(x:1,y:3);


varv1 =pt.scale;

pt.scale=2;

varv2 =pt.scale;

原文链接:https://www.f2er.com/swift/326946.html

猜你在找的Swift相关文章