Created
November 14, 2020 14:45
-
-
Save wissalHaji/55b81eb51d6d6cc8705ac07a9759d286 to your computer and use it in GitHub Desktop.
Memory array in solidity example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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