pragma solidity ^0.4.18; // Creating a contract contract Types { // Declaring a dynamic array uint[] data; // Declaring a state variable uint8 j = 0; // Function to demonstrate while loop and return the array function loop() public returns (uint[] memory) { while (j < 5) { j++; data.push(j); } return data; } // Function to get the data array function getData() public view returns (uint[] memory) { return data; } }
0.4.18