I want to call a function in Go, and attach to the argument values the argument names
func sum(a int, b int) int {
return a + b
}
func main() {
result := sum(a=4, b=5) // result == 9
}
Is it possible?
I want to call a function in Go, and attach to the argument values the argument names
func sum(a int, b int) int {
return a + b
}
func main() {
result := sum(a=4, b=5) // result == 9
}
Is it possible?
There is no such thing like named arguments in go
At the moment Go does not have a way to use named argument in functions. If you really need to use named arguments you can try this library go-named-params
© 2022 - 2024 — McMap. All rights reserved.
a
andb
as local arguments, I mentioned them as the arguments in the function signature. But I understand, there is no such thing named arguments in go...Thanks! – Backfield