1
クラスのメンバメソッド内の現在のオブジェクトを参照することは可能ですか? $childWidget SetParent $self
で$self
の等価何ができるかItclのクラスメソッド内の自己参照
itcl::class widget {
private variable inst
method ChildCount {} {
return [llength [keylkeys inst children]]
}
method AddChild {childWidget} {
inst children.[ChildCount] $childWidget
# ***HOW TO GET THIS WORKING?***
$childWidget SetParent $self
}
}
: 親切に以下のコードを考えてみ?
これは答えです:itclはメソッド本体の内部に表示されている 'this'という名前の変数にある現在のオブジェクトへの参照を提供します。 –