I have just started to learn Go
language and still trying to digest few things.
I wrote a function add
as:
func add(a int, b int) int {
return a + b
}
// works fine
func add(a, b) int {
return a + b
}
// ./hello.go:7: undefined: a
// ./hello.go:7: undefined: b
// Digested: May be I need to give type
func add(a, b int) int {
return a + b
}
// works fine interestingly
func add(a int, b) int {
return a + b
}
// ./hello.go:7: final function parameter must have type
I am really confused or due to lack of knowledge unable to understand the use case of
final function parameter must have type
.