_if _not some_set.empty?
_then
_for a_value _over some_set.fast_elements()
_loop
write(a_value)
_endloop
_endif
... what's the point, I asked, of asking SOME_SET if it is empty? If it is empty, then the loop won't be entered anyways and now you are just cluttering up the file with redundant code. It seems that the following should be equivalent...
_for a_value _over some_set.fast_elements()
_loop
write(a_value)
_endloop
Well, today I learned that those two statements are not equivalent. If you use the _finally keyword, its scope will always be processed, even if the iterator has not even run a single loop.
MagikSF> _for a_value _over {:a,1,"bb",300}.fast_elements()
_loop
show(a_value)
_finally
write("Finally")
_endloop
$
:a
1
"bb"
300
Finally
MagikSF> _for a_value _over {}.fast_elements()
_loop
show(a_value)
_finally
write("Finally")
_endloop
$
Finally
So lesson learned... if your _finally block of code expects some value to be set in the main _loop block, be sure to put error handling in there for the case where the loop had no iterations to process.