标签:
class Rect{
private struct swidth{
static var width: Int = 0
}
private struct sheight{
static var height: Int = 0
}
internal class var width: Int{
get{
return swidth.width
}
set{
swidth.width = newValue
}
}
internal class var height: Int{
get{
return sheight.height
}
set{
sheight.height = newValue
}
}
class func setSize(w: Int, height: Int){
Rect.width = w
Rect.height = height
}
class func getArea() -> Int{
return Rect.width * Rect.height
}
}
Rect.setSize(20, height: 50)
Rect.width
Rect.height
Rect.getArea()
// 闭包
class Student{
var score: [Int] = {
var scores: [Int] = Array()
for m in 0...3{
scores.append(m)
}
return scores
}()
}
var stu = Student()
stu.score
Student().score
标签:
原文地址:http://www.cnblogs.com/lianfu/p/5095975.html