Skip to content

Instantly share code, notes, and snippets.

@jigar23
Created June 5, 2018 15:55
Show Gist options
  • Save jigar23/194af74e10fcad92e6561bd9b2f488b2 to your computer and use it in GitHub Desktop.
Save jigar23/194af74e10fcad92e6561bd9b2f488b2 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Debugging {
uint[] private vars;
function assignment() public pure {
// allocates the memory first before assigning
// so we'll see 2 values in the stack first
// and then the assignment takes place
uint myValue1 = 1;
uint myValue2 = 2;
assert(myValue1 == myValue2);
}
function memoryAlloc() public pure {
string memory myString = "test1";
string memory myString1 = "hello";
assert(bytes(myString).length == 10);
}
// LEngth of array stored first
// then the array value
// As the length expands since its a dynamic array, the length
// value will be modified
function storageAlloc() public {
vars.push(2);
vars.push(4);
assert(vars.length == 4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment