I really don`t know why the output of the code:
State_Values = List[];
Print[Length[{}]]
Print[Length[State_Values]];
is :
0
2
Can't suggest any reason. Maybe it is sth very stupid, but I can't see. Thank you.
Not stupid, but you have made a subtle mistake. The underscore in State_Values
turns it into a Pattern
, not a List
. You can find this out using the function Head[]
.
stateValues = List[];
Length[stateValues]
Length[{}]
Out[11]= 0
Out[12]= 0
As you can see, this is correct and expected. Introduce the underscore, though, and it all breaks:
state_Values = List[];
Length[state_Values]
Head[state_Values]
Head[stateValues]
Out[16]= 2
Out[17]= Pattern
Out[18]= List
It's much easier to see if you're using the GUI version of Mathematica since it highlights Pattern
variables differently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With