Skip to main content

親クラスのコンストラクタを呼ぶ(super)

Python

py
class B(A):
def __init__(self):
super().__init__() # Python3

Python2 の場合は

py
class B(A):
def __init__(self):
super(B, self).__init__()

親クラス(かその上の方)で object を継承していないと TypeError: must be type, not classobj みたいなエラーが出るよ

Swift

swift
super.init(..)