[Ethereum] TypeError: Type address[1] memory is not implicitly convertible to expected type address[] memory

solidity

So I'm trying to call Comptroller's function enterMarkets(address[] calldata cTokens) returns (uint[] memory). The problem that I have is if I call the function with my array of markets, it gives me the error, TypeError: Type address[1] memory is not implicitly convertible to expected type address[] memory.

I understand that the function expects an address array of an undefined length, but every method I can think of to pass an array to the function gives me the same error. For example, the following methods return the same error:

address[] memory markets = [address(cdaitoken)];
comptroller.enterMarkets(markets);
comptroller.enterMarkets([address(cdaitoken)]);

Best Answer

Solution if anyone's curious:

address[] memory markets = new address[](1)
markets[0] = address(cdaitoken)