A
Aryeh M. Friedman
Lets say I have something like this:
// yes this compiles I cut and pasted this from a example I wrote
// specificallu for this post
public enum foo {
Ack(10);
private foo(int val)
{
setVal(val);
}
public void setVal(int val)
{
Val=val;
}
public int getVal()
{
return Val;
}
private int Val;
public static void main(String [] arg)
{
System.out.println(Ack.getVal());
Ack.setVal(20);
System.out.println(Ack.getVal());
}
}
is there any reason why I shouldn't do something like it, assume that
main() is for debugging only and the real code has the actual user's of
the enum values calling get/setVal.
The idea here is I am writting a parser that needs to reconize different
types of delims (depending on input type) and came up with the idea of
just redefining an enum thus the code is still symbolic but dynamic.
// yes this compiles I cut and pasted this from a example I wrote
// specificallu for this post
public enum foo {
Ack(10);
private foo(int val)
{
setVal(val);
}
public void setVal(int val)
{
Val=val;
}
public int getVal()
{
return Val;
}
private int Val;
public static void main(String [] arg)
{
System.out.println(Ack.getVal());
Ack.setVal(20);
System.out.println(Ack.getVal());
}
}
is there any reason why I shouldn't do something like it, assume that
main() is for debugging only and the real code has the actual user's of
the enum values calling get/setVal.
The idea here is I am writting a parser that needs to reconize different
types of delims (depending on input type) and came up with the idea of
just redefining an enum thus the code is still symbolic but dynamic.