You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import "fmt"
func add (a int, b int) (sum int) { // here we are defining the variable name of what we are returning
sum = a + b // so no need for a return statement, go takes care of it
}
func main() {
sum := add(3, 5)
fmt.Println(sum) // prints 8
}
Errors:
./prog.go:7: missing return at end of function
Corrections needed:
Still need to use 'return'.
Named return just helps in skipping declaration step.
Also ensures all intended values are returned automatically.
No need to specify names but return still required.
The text was updated successfully, but these errors were encountered:
Found some incorrect explanations, syntax in the Golang tutorial.
Code:
Errors:
Corrections needed:
Code:
Errors:
Corrections needed:
The text was updated successfully, but these errors were encountered: