Re: Why doesn't foreach return a value



There is indeed one logical gotcha for the "return value" of break/
continue:

foreach i {1 2 3} {set a [break b]}

The assignment to a will not take place, because the loop body is left
before. So who will receive the "b" value? One could fantasize that it
ends up as foreach's return value (and similarly for [for] and
[while]):

set status [foreach i {1 2 3} {if $x {break b}}]

If x is non-zero, status would be "b"; else "" as usual.
.