pragma solidity >= 0.8.2 <0.9.0;
contract Types {
// Declaring a dynamic array
uint[] data;
uint8 j = 0;
function loop() public returns(uint[] memory){
while(j < 5) {
j++;
data.push(j);
}
return data;
}
}
On Remix IDE getting the error. ParserError: Function, variable,
struct or modifier declaration expected.
--> contracts/Types.sol:5:16:
|
5 | contract Types {
| ^
-
2I checked the code in Remix and it does compile and deploy successfully. Could use some linting, but it does work.– AkeSep 21 at 7:38
-
1I had the same positive result, can't find any errors...– titan2gmanSep 21 at 7:45
-
the code compiles well on remix– Zartaj AfserSep 21 at 9:06
1 Answer
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract Types {
uint[] data;
uint8 j = 0;
function loop() public returns (uint[] memory) {
while (j < 5) {
j++;
data.push(j);
}
return data;
}
}
as far as i can see, you just forget the license identifier to the top