digitalmars.D.learn - Access original data from array
- Moritz Warning <moritzwarning web.de> Sep 30 2009
- Tom S <h3r3tic remove.mat.uni.torun.pl> Sep 30 2009
- Tom S <h3r3tic remove.mat.uni.torun.pl> Sep 30 2009
- Moritz Warning <moritzwarning web.de> Sep 30 2009
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?
}
Sep 30 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
Sep 30 2009
Tom S wrote:2) Perhaps a custom-fit Delorian will do.
DeLorean, even.
Sep 30 2009
On Thu, 01 Oct 2009 05:02:10 +0100, Tom S wrote:Moritz Warning wrote:Hi, how can I access the original value for xs?
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.
Quirky game...2) Perhaps a custom-fit Delorian will do.
- I don't do coding while driving at > 88Mph.3) If all else fails, I'm afraid you'll have to resort to copying the contents of xs prior to overwriting them.
Thanks!
Sep 30 2009









Tom S <h3r3tic remove.mat.uni.torun.pl> 