[Swift-devel] file declaration inside foreach

Ben Clifford benc at hawaga.org.uk
Wed Apr 25 02:35:25 CDT 2007



On Tue, 24 Apr 2007, Mihael Hategan wrote:

> Because the jobs are independent. You are creating iteratiion-local
> variables between which there is no dependency.
> 
> What you want is something like this:
> file[] lattice <...>;
> lattice[0] = initialLattice;
> for i in 1...2 {
>   lattice[i] = app(lattice[i-1]);
> }

I just tried this:

int r[] = [1:2:1];
int k[];

k[0]=100;

foreach i in r {
k[i] = k[i-1] + i;
}

and I get this:

$ swift for.swift 
Swift V 0.0405
RunID: 2hp99svgoyjd2
Execution failed:
        String index out of range: 0


:-(

-- 



More information about the Swift-devel mailing list