0

I get the following error, how to resolve it?

Expected type name function Array_Data () public view returns (memory uint []) {^ ---- ^.
pragma solidity >=0.5.0 <0.6.0;

contract Lock {
    uint[] public _gas_left;
    
    function closeAccount() public {
        _gas_left.push(gasleft());
    }
    
    function Array_Data() public view returns(memory uint[]) {
        uint[] memory arrayOfgas = new uint[](20);
        for (uint i = 0; i < _gas_left.length; i++)
            arrayOfgas[i] = _gas_left[i];
        return arrayOfgas;
    }
} 

How can this be resolved?

1

This should resolve your error.

It should be returns(uint[] memory) not returns(memory unit[])

pragma solidity >=0.5.0 <0.6.0;

contract Lock {
    uint[] public _gas_left;
    
    function closeAccount() public {
        _gas_left.push((gasleft()));
    }
    
    function Array_Data() public view returns(uint[] memory){
        uint[] memory arrayOfgas = new uint[](20);
        for (uint i = 0; i < _gas_left.length; i++)
            arrayOfgas[i] = _gas_left[i];
        return arrayOfgas;
    }
} 
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.