Consider the following 2 alternatives for implementing the same function that returns a result value. The second syntax is my favorite and I use it throughout my code (I am currently developing a commercial accounting application in GOlang (based on lxn/walk)).
func Sum(a, b int) int {
return a + b
}
func Sum(a, b int) (total int) {
total = a + b
}
But when using the predefined variable it seems very illogical to me that GO complains about leaving out the final return statement so I must correct this by doing this:
func Sum(a, b int) (total int) {
total = a + b
return
}
My proposal is to NOT generate the "missing return at end of function" error in the latter case allowing programmers to leave out this obviously superfluous line of code.
Consider the following 2 alternatives for implementing the same function that returns a result value. The second syntax is my favorite and I use it throughout my code (I am currently developing a commercial accounting application in GOlang (based on lxn/walk)).
But when using the predefined variable it seems very illogical to me that GO complains about leaving out the final return statement so I must correct this by doing this:
My proposal is to NOT generate the "missing return at end of function" error in the latter case allowing programmers to leave out this obviously superfluous line of code.