Access original data from array

Tom S h3r3tic at remove.mat.uni.torun.pl
Wed Sep 30 21:02:10 PDT 2009


Moritz Warning wrote:
> Hi,
> 
> how can I access the original value for xs?
> 
> I assume that xs is allocated at program start,
> because I don't get an access violation on gnu/linux
> when I reassign values.
> 
> But how can I access the original value?
> Do I have to keep a copy before xs is modified?
> 
> import tango.io.Stdout;
> 
> 
> void main(char[][] args)
> {
>     static char[][2] xs = ["abc", "123"];
>     xs[0] = "foo";
>     xs[1] = "bar";
>     
>     foreach(x; xs)
>     {
>         Stdout(x).newline;
>     }
> 
>     //how to print "abc" "123" now?
> }

You were probably looking for the old meaning of .init, but it's gone 
now, so I present these alternative fixes:

1) You need to load the state of the game from before overriding xs. I 
recommend Quick Save and Quick Load. Often bound to F5 and F9.

2) Perhaps a custom-fit Delorian will do.

3) If all else fails, I'm afraid you'll have to resort to copying the 
contents of xs prior to overwriting them.


-- 
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode


More information about the Digitalmars-d-learn mailing list