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
Last Updated on 2022-01-05 by gantovnik
Recent Comments