Skip to content

Instantly share code, notes, and snippets.

@wissalHaji
Created November 14, 2020 14:45
Show Gist options
  • Save wissalHaji/55b81eb51d6d6cc8705ac07a9759d286 to your computer and use it in GitHub Desktop.
Save wissalHaji/55b81eb51d6d6cc8705ac07a9759d286 to your computer and use it in GitHub Desktop.
Memory array in solidity example
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract B {
function createMemArrays() external view {
uint256[20] memory numbers;
numbers[0] = 1;
numbers[1] = 2;
uint256 users_num = numbers.length;
address[users_num] memory users1; // ERROR : expected integer literal
// or constant expression
address[] memory users2 = new address[](users_num);
users2[0] = msg.sender; // OK
users2.push(msg.sender); // ERROR : member push is not available
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment