2
我是TCL中面向对象编程的新手。我安装了包含TclOO包的ActiveTCL 8.6,以便在TCL中使用类和对象。我想创建一个对象并调用各种过程以使用它。例如,我尝试了下面这段代码:TCL:将对象作为过程的参数传递给ActiveTcl 8.6
oo::class create Test {
method func {} {
puts "Hello World!"
}
}
proc speak { myObj } {
myObj func
}
Test create testObj
testObj func; # This prints "Hello World!"
speak testObj; # This raises an error -> invalid command name "myObj"
我应该怎么做才能在“speak”过程中使用对象testObj?
非常感谢! – Rubeinstein