1

from solidity: TypeError: Return argument type uint256 is not implicitly convertible to expected type (type of first return variable) int256. --> sample.sol:72:24:

cocontract fixedsizeArray{

    uint[5] public arr= [10,19,15,78,56];

    function array() public view  returns(int){
            uint odd;
            odd = arr[3];
            return odd;

    }
}
1
  • Thanks buddy for this contribution Aug 12, 2022 at 16:21

1 Answer 1

0

The arr array has defined as uint array. If you want return this array, you must change the returns values inside array() function from

int

to

uint

Like in this way:

pragma solidity ^0.8.0;

contract fixedsizeArray{

    uint[5] public arr= [10,19,15,78,56];

    function array() public view returns(uint){
        uint odd;
        odd = arr[3];
        return odd;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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