- 枚举类型
- 枚举类型只有case,没有常量变量(不同地方)
- 能够有实例方法,类型方法。
- 能够有指定构造器,没有便利构造器(不同地方)
- 能够有可变实例方法(不同地方)
- 能够有下标
- 它的原始值类型只有Int,Doublt, Float, Character类型,默认是Int类型,Character类型要赋初始值
- 结构体
- 结构体中只有let,var变量(不同地方)
- 能够有实例方法,类型方法。
- 能够有指定构造器没有遍历构造器(不同地方)
- 能够有可变实例方法(不同地方)
- 默认有两个指定构造器,一个无参数构造器,一个逐一成员构造器。(不同地方)
- 能够有下标
- 类
- 类中只有let,var属性(不同地方)
- 能够有实例方法,类型方法。
- 能够有指定构造器和遍历构造器(不同地方)
- 默认只有一个无参数的构造器(不同地方)
- 能够有下标
enum TestEnum {
case one, two, three
func test(){
}
static func test(){
}
init(name: String){
switch name {
case "one":
self = .one
default:
self = .one
}
}
mutating func test1(){
self = .one
}
}
struct TestStruct {
let b = 4
var a = 4
func test() {
}
static func test(){
}
init() {
}
mutating func test1(){
self.a = 5
}
}
class TestClass {
let a = 3
var b = 4
func test() {
}
static func test(){
}
init() {
}
convenience init(name: String){
self.init()
}
}
复制代码