Hey, I am a fairly novice coder and I am having some trouble making an elegant solution to the following problem: (pseudocode)
------------
switch (something)
{
case (something1)
tabel = tabel_1
case (something2)
tabel = tabel_2
etc....
}
number = tabel[some int].number;
.....
------------
A solution would of course be just to have
case (something1)
number = tabel_1[some int].number
but there is a lot of code that has to be at every case in the switch making it very repeditive and long, and not as elegant as I hoped for.
So I guess my question is;
Is there a way to 'point' to a tabel that was previously decided on in a switch statement ?
Thanks for your time.
------------
switch (something)
{
case (something1)
tabel = tabel_1
case (something2)
tabel = tabel_2
etc....
}
number = tabel[some int].number;
.....
------------
A solution would of course be just to have
case (something1)
number = tabel_1[some int].number
but there is a lot of code that has to be at every case in the switch making it very repeditive and long, and not as elegant as I hoped for.
So I guess my question is;
Is there a way to 'point' to a tabel that was previously decided on in a switch statement ?
Thanks for your time.
Comment