Passing list to Tcl procedure

前端 未结 3 795
日久生厌
日久生厌 2021-02-13 02:56

What is the canonical way to pass a list to a Tcl procedure?

I\'d really like it if I could get it so that a list is automatically expanded into a variable number of arg

3条回答
  •  自闭症患者
    2021-02-13 03:09

    To expand on RHSeeger's answer, you would code myprocedure with the special args argument like this:

    proc myprocedure {opt1 opt2 args} {
        puts "opt1=$opt1"
        puts "opt2=$opt2"
        puts "args=[list $args]" ;# just use [list] for output formatting
        puts "args has [llength $args] elements"
    }
    

提交回复
热议问题