我有一个有几个内部值的类:
private variable layer_type
private variable color
private variable name
private variable thickness
private variable conductivity
private variable permittivity
private variable loss_tangent
我想用用户提供给构造函数的值来启动它们,但是由于它们中有 7 个,为了减少混乱和代码大小,我在一个循环中完成了它:
constructor {in_layer_type in_color in_conductivity in_loss_tangent in_name in_permittivity in_thikness f_row frame} {
foreach var [list layer_type color conductivity loss_tangent name permittivity thikness] {
set $var [set in_$var]
}
在编写所有命令时,这种方法是否有任何区别(性能方面)set
?
set layer_type $in_layer_type
set color $in_color
#...
set thickness $in_thickness