Closed bcardarella closed 1 month ago
_
means the argument has no label. So in SwiftUI you write this as:
tabItem({ Text("Label") })
but this would cause an error:
tabItem(label: { Text("Label") })
// error: Extraneous argument label 'label:' in call
yes I saw that error and looked at the Swift source, my question is if label
is a supported named argument in the original SwiftUI, I see it in the Apple docs or am I misunderstanding.
I think you're misunderstanding the function signature. In that example, the argument label is _
, with the second label being label
(for use within the function body).
When the first argument label is a wildcard _
character, you cannot pass a label.
func myFunction(_ unlabeled: Any) -> Any {
// use `unlabeled` in here
}
// call without a labeled argument.
myFunction(5)
myFunction(unlabeled: 5) // this form is invalid
A wildcard argument label does not mean the label is optional, it means the label cannot be used at the call site at all.
ah ok, it's not a named argument. That makes sense
works but from the Apple documentation:
I presume that the
_
default named argument's name islabel
so if I try:the modifier doesn't match in the client: