Re: Why doesn't foreach return a value
- From: suchenwi <richard.suchenwirth-bauersachs@xxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 00:46:39 -0800 (PST)
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.
.
- Follow-Ups:
- Re: Why doesn't foreach return a value
- From: Fredderic
- Re: Why doesn't foreach return a value
- References:
- Re: Why doesn't foreach return a value
- From: Rufus V. Smith
- Re: Why doesn't foreach return a value
- From: Mark Janssen
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- From: Darren New
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- From: Darren New
- Re: Why doesn't foreach return a value
- From: tom.rmadilo
- Re: Why doesn't foreach return a value
- Prev by Date: Re: Why doesn't foreach return a value
- Next by Date: Re: clock scan
- Previous by thread: Re: Why doesn't foreach return a value
- Next by thread: Re: Why doesn't foreach return a value
- Index(es):