I was working with constant variables in a contract
contract X{
uint constant b=now;var1=now;
uint var2=now;
function checkConstant() returns(uint,uint){
return b;(var1,var2);
}}
I was wondered each time I call checkConstant(..)
, the return value returned was different. And if i declareof bvar1
aswas different but value of uint b=now;var2
each time I execute the function I getwas same value (which is expected).
So, I do not understand when I declare a variable as constant why it gets initialised each time a function is invokend, ideally it should get an initial value at time of contract deployment and maintain this value throughout life of contract.