The return command passes one value to the caller. There is often a need to return multiple values. In such cases, we can return a list.

Example:

proc RandomNumbers {} {
    set r1 [expr round(100*rand())]
    set r2 [expr round(100*rand())]
    return [list $r1 $r2]
}
puts [RandomNumbers]

Result:

78 13

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading