Skip to content

Instantly share code, notes, and snippets.

@jtakalai
Created November 19, 2018 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtakalai/30f2ac4c446975c1b00b97b37140e6fc to your computer and use it in GitHub Desktop.
Save jtakalai/30f2ac4c446975c1b00b97b37140e6fc to your computer and use it in GitHub Desktop.
Testing "continue" keyword to replicate whas was reported fixed in https://solidity.readthedocs.io/en/latest/050-breaking-changes.html
pragma solidity ^0.4.22;
/** @dev herp derp */
contract Testing {
event Show(bytes s);
bytes32[] derp;
function continueTest() public {
derp.push(0x123);
derp.push(0x0);
derp.push(0x345);
derp.push(0x0);
for (uint8 i = 0; i < derp.length; i++) {
bytes32 x = derp[i];
if (x == 0x0) continue;
emit Show(abi.encodePacked(x));
}
}
function continueTest2() public {
derp.push(0x123);
derp.push(0x0);
derp.push(0x345);
derp.push(0x0);
uint8 i = 0;
do {
bytes32 x = derp[i++];
if (x == 0x0) continue;
emit Show(abi.encodePacked(x));
} while (i < derp.length-1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment