- 访问权限:内部可写,外部只读
public class Person {
public private(set) var name: String
}
- 特殊的字面常量
Literal | Type | Value |
---|---|---|
#file | String | The name of the file in which it appears. |
#line | Int | The line number on which it appears. |
#column | Int | The column number in which it begins. |
#function | String | The name of the declaration in which it appears. |
#file 相当于Objective-C中的 __FILE__
#line 相当于Objective-C中的 __LINE__
#column 相当于Objective-C中的 __COLUMN__
#function 相当于Objective-C中的 __FUNCTION__
现在我们可以优雅的打印信息了:
print(type(of: self), #function)
网友评论