I'm a Python Developer jumping into Solidity and I feel like I'm missing something about variables and scope.
How do I set and access variables outside of a function's scope?
I can't seem to add spins ( simple uint ) to my spin history ( uint[] ) and access them elsewhere. I can use push and get it in an array within the same function, but it doesn't update the State level variable.
contract GoldenEgg{
uint[] public spinHistory;
function spin() constant returns (uint) {
uint spin = uint8(uint256(keccak256(block.timestamp, block.difficulty))%37);
addToHistory(spin);
return spin;
}
function getHistory() constant returns (uint[]) {
return spinHistory;
}
function addToHistory( uint spin ) constant returns (uint[]) {
spinHistory.push(spin);
return spinHistory;
}}