Literal <collection-expression>

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Literal <collection-expression>

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:20 pm

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

Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 29 guests