You can't access them with Solidity. You may be able to use inline assembly to do it, but there is no point really, and you should just give them a name if you want to use them in the function.
There are a few use cases for unnamed parameters. They can be useful if you have a function that overrides another function, but you only need certain parameters from that function. They are also often used for return parameters. For example:
interface A {
function doSomething (uint256 a, uint256 b) external returns (uint256);
}
contract B is A {
function doSomething(uint256, uint256 b) override external returns (uint256) {
return b;
}
}
Since it's not accessing a, you can omit the name in the override function. It also returns directly in the function, so there is no need to name the return parameter, like:
contract B is A {
function doSomething(uint256, uint256 b) override external returns (uint256 c) {
c = b;
}
}
This can be useful or not, depending on your use case. Removing the parameter altogether would result in a different function signature, and in this case a compiler error since the function does not implement the interface properly.
how can we use them inside a function- you're obviously going to write code inside that function, so start by giving a name to each one of those unnamed parameters. In other words, the answer to "how to use unnamed parameters" is "by naming them"!!! – goodvibration Sep 16 '20 at 16:33