Swift2.2 failable initializer允许提前返回nil以及和Java的不同
发现swift和java有一个完全不一样的地方 在swift中, 子类必须先初始化子类的所有属性, 然后才能调用父类的构造器. 而在java中.super调用必须出现在构造函数的第一行. java代码 public class Dog { String name; Dog(String name){ this.name = name; } } class NoisyDog extends Dog { int age; NoisyDog(String name) { // 交换以下两行的顺序会报错: Constructor call must be the first statement in a constructor super(name); this.age = 5; } } 对应的swift代码: class Dog { var name: String; init(name: String){ self.name = name; } } class NoisyDog: Dog { var age: Int override init(name: String) { //交换以下两行的顺序会报错error: property 'self.age' not initialized at super.init call self.age = 5; super.init(name: