Page 1 of 1

Literal <collection-expression>

Posted: Fri Aug 07, 2009 2:20 pm
by ConvertFromOldNGs
by John Porter >> Wed, 1 Dec 1999 0:08:04 GMT

There is a useful construct in UNIX shell programming, eg

for s in "fred" "sally" do
<whatever>
done

The best I have been able to do in Jade is this:

vars
s:String;
sA:StringArray;begin

create sA transient;
sA.add("fred");
sA.add("sally");
foreach s in sA do
<whatever>
endforeach;
epilog
delete sA;
end;

Is there an easier way? I'd like to do something like

foreach s in "fred" "sally" do
<whatever>
endofreach;

In other words, specify a <collection-expression> as a literal.

On a related topic, is it possible to initialise an entire array?

sA:={"fred","sally");

Cheers,
John P