I am trying to pass a default value in solidity but get the following error: "Invalid implicit conversion from enum tlb.Category to enum tlb.Category[] memory requested"

Does anybody have an idea of how to fix this?

    uint256 public pageNo = 0;
    enum Category {DEFAULT, I, II, IIIA, IIIB}
    mapping(uint => TLB) public TLBs;
    struct TLB{
        uint flightNo;
        string flightFrom;
        string flightTo;
        uint256[3] reportDate;
        Category[] category;
        bool EtopsFlight;
        string maintCheck;
        uint licenseNo;
        uint station;
        bool CaaCertification;
        bool handlingAgent; 
        uint CertNo;
    function addTLB(uint _flightNo, string memory _flightFrom, string memory _flightTo, uint256[3] memory _reportDate) public {
        Category _category = Category.DEFAULT;
        TLBs[pageNo] = TLB(_flightNo, _flightFrom, _flightTo, _reportDate, _category, false, "", 0, 0, false, false, 0);

2 Answers 2


Your struct is expecting an array of Category Category[] category; and you are passing just a single enum value. If you just have to pass a single value change the struct variable to Category category; and it will work fine.


You want to pass an Enum value of type Category to your TLBs map, so you have to declare category in your struct TLB as Category.

Category[] category; must be as follows Category category;

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.