Avatar
omochimetaru 8/2/2018 10:02 AM
これだとコンパイル通る protocol Animal { func foo() -> Self } class Cat: Animal { func foo() -> Self { return self } } class Siamese: Cat { } let siamese = Siamese() let cat = siamese.foo()
10:02 AM
return self 以外にも、 type(of: self).init() などで Self 型の値が作れる。