Reader small image

You're reading from  Blockchain for Enterprise

Product typeBook
Published inSep 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788479745
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Narayan Prusty
Narayan Prusty
author image
Narayan Prusty

Narayan Prusty is a full-stack developer. He works as a consultant for various start-ups around the world. He has worked on various technologies and programming languages but is very passionate about JavaScript, WordPress, Ethereum, Solr, React, Cordova, MongoDB, and AWS. Apart from consulting for various start-ups, he also runs a blog titled QNimate and a video tutorial site titled QScutter, where he shares information about a lot of the technologies he works on.
Read more about Narayan Prusty

Right arrow

Data locations in Solidity


Unlike other programming languages, Solidity's variables are stored in the memory and the database, depending on the context.

There is always a default location, but it can be overridden for complex types of data, such as strings, arrays, and structs, by appending storage or memory to the type. Memory is the default for function parameters (including return parameters), and storage is for local and state variables (obviously).

 

Data locations are important because they change the behavior of assignments:

  • An independent copy is always created for assignments between storage variables and memory variables. No copy is created, however, for assignments from one memory-stored complex type to another.
  • An independent copy is always created for an assignment to a state variable (even from other state variables).
  • Memory-stored complex types cannot be assigned to local storage variables.
  • If state variables are assigned to local storage variables, the local storage variables point...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Blockchain for Enterprise
Published in: Sep 2018Publisher: PacktISBN-13: 9781788479745

Author (1)

author image
Narayan Prusty

Narayan Prusty is a full-stack developer. He works as a consultant for various start-ups around the world. He has worked on various technologies and programming languages but is very passionate about JavaScript, WordPress, Ethereum, Solr, React, Cordova, MongoDB, and AWS. Apart from consulting for various start-ups, he also runs a blog titled QNimate and a video tutorial site titled QScutter, where he shares information about a lot of the technologies he works on.
Read more about Narayan Prusty