I am facing an issue with my code and is giving errors: I am getting is for uc
saying "unnamed and mixed parameters".
Can you help me with this?
func(uc fyne.URIWriteCloser, error) {
...
}
CodePudding user response:
As specified in the specs for Function Types:
Within a list of parameters or results, the names (IdentifierList) must either all be present or all be absent.
- If present, each name stands for one item (parameter or result) of the specified type and all non-blank names in the signature must be unique.
- If absent, each type stands for one item of that type.
Parameter and result lists are always parenthesized except that if there is exactly one unnamed result it may be written as an unparenthesized type.
So either remove uc
, or add err error
.
CodePudding user response:
It looks like you declared a function that has a named, and an unnamed parameter, which you cannot do.
There's two ways you can handle parameters in a func. You can either name all of the parameters, or provide no names to any of the parameters.
This is a valid func signature with both parameters named.
func(uc fyne.URIWriteCloser, err error) {
// do something
}
And so is this, without naming the parameters.
func(fyne.URIWriteCloser, error) {
// do something
}
If you were to name the first param, but leave the second param unnamed, like in the image
func(uc fyne.URIWriteCloser, error) {
// do something
}
Then you would see this error
Function has both named and unnamed parameters
So, the problem is that the second param simply declares the param type and not the name, while the first param is defining the type and naming the param.