Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. Data locations are important because they change how assignments behave:
  2. assignments between storage and memory and also to a state variable (even
  3. from other state variables) always create an independent copy. Assignments
  4. to local storage variables only assign a reference though, and this
  5. reference always points to the state variable even if the latter is changed
  6. in the meantime. On the other hand, assignments from a memory stored
  7. reference type to another memory-stored reference type do not create a copy
  8.  
  9. pragma solidity ^0.4.0;
  10. contract C {
  11. uint state_variable; // same as global storage variable
  12.  
  13. function test() returns uint{
  14. uint local_variable = 10; //same as local storage variable
  15. return local_variable * state_variable;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement