Rule 8

Assignments to a memory variable from another memory variable do not create a copy for reference types; however, they do create a new copy for value types. The code listing shown in the following screenshot illustrates that value type variables in memory are copied by value. The value of localVar1 is not affected by change in value of the localVar2 variable:

The code listing shown in the following screenshot illustrates that reference type variables in memory are copied by reference. The value of otherVar is affected by change in the someVar variable:

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.