Re: naming a variable at runtime

2014-05-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 13/05/14 06:32, InfinityPlusB wrote: yup, that will work. If I wasn't hell bent on naming variables, I probably would have figured this out. :P Perhaps you could use an associative array. Then you get sort of named variables. -- /Jacob Carlborg

Re: naming a variable at runtime

2014-05-12 Thread safety0ff via Digitalmars-d-learn
You should look into associative arrays ( http://dlang.org/hash-map .) Example: import std.stdio; void main() { int[][string] mybobs; mybobs[bob_1] = [-1, -1, 1, -1, -1]; mybobs[bob_2] = [-1, 1, 1, 1, -1]; mybobs[bob_3] = [-1, 1, 1, 1, -1];

Re: naming a variable at runtime

2014-05-12 Thread InfinityPlusB via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 03:54:33 UTC, safety0ff wrote: You should look into associative arrays ( http://dlang.org/hash-map .) Example: import std.stdio; void main() { int[][string] mybobs; mybobs[bob_1] = [-1, -1, 1, -1, -1]; mybobs[bob_2] = [-1, 1, 1, 1, -1];

Re: naming a variable at runtime

2014-05-12 Thread Ali Çehreli via Digitalmars-d-learn
On 05/12/2014 08:47 PM, InfinityPlusB wrote: I want to be able to name the rows, as they are built. First, no, you cannot name variables at run time because variables are concepts of source code; they don't exist in the compiled program. So when row 1 is read in I get int[] bob_1 = new

Re: naming a variable at runtime

2014-05-12 Thread InfinityPlusB via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 04:26:04 UTC, Ali Çehreli wrote: On 05/12/2014 08:47 PM, InfinityPlusB wrote: I want to be able to name the rows, as they are built. First, no, you cannot name variables at run time because variables are concepts of source code; they don't exist in the compiled