Solidity – Understanding the Point of Omitted Function Parameters in Solidity

solidity

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;

contract C {
    // omitted name for parameter
    function func(uint k, uint) public pure returns(uint) {
        return k;
    }
}

The code above has two parameters: k and another unnamed parameter.

What is the point of having an unnamed parameter?

One use case I can think of is function overriding but what else can it be used for? Is it okay if we won't pass unnamed parameter?

Best Answer

I think you got it. Overriding, and then sometimes you'll see this kind of thing if you're trying to subscribe to a standard (e.g. ERC721) and you actually don't need that variable for how you're handling the implementation.

Related Topic