0

I have this error but I do not know what is wrong?

browser/arry.sol:6:58: ParserError: Expected ',' but got 'memory'
    function addScore(unit24 s) public returens(unit24 []memory){
                                                         ^----^

this is my code

pragma solidity^0.5.0;

contract Score {
    unit24[]score;

    function addScore(unit24 s) public returens(unit24 []memory){
        score.push(s);
        return score;
    }

    function getLength()view public returens(unit){
        return score.length;
    }

    function clearArray() public returens(unit24 [] memory){
        delete score;
        return score;
    }
}
0

You misspelled uint (you wrote unit) and returns (you wrote returens). Code with those misspellings corrected compiles fine:

pragma solidity^0.5.0;

contract Score {

    uint24[] score;

    function addScore(uint24 s) public returns (uint24[] memory) {
        score.push(s);
        return score;
    }

    function getLength() view public returns (uint) {
        return score.length;
    }

    function clearArray() public returns (uint24[] memory) {
        delete score;
        return score;
    }
}
  • I misspelled , you are right, thank you – vob67 May 22 at 5:09

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.