Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Data locations are important because they change how assignments behave:
- assignments between storage and memory and also to a state variable (even
- from other state variables) always create an independent copy. Assignments
- to local storage variables only assign a reference though, and this
- reference always points to the state variable even if the latter is changed
- in the meantime. On the other hand, assignments from a memory stored
- reference type to another memory-stored reference type do not create a copy
- pragma solidity ^0.4.0;
- contract C {
- uint state_variable; // same as global storage variable
- function test() returns uint{
- uint local_variable = 10; //same as local storage variable
- return local_variable * state_variable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement