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
func c(n, m int) (r int) {
r= 1;
for i:=0; i!=m; i++ { r*= n-i; r/= i+1}
return
}
The final return statement should be unnecessary, but is demanded by
the compiler. With named return values the compiler should be able to make
the return code at the end of the function.
The text was updated successfully, but these errors were encountered:
We thought about this while designing the feature
and decided that since you can still write "return 5"
and not use r, it is important to signal the
"return the current value of r" case explicitly,
in case you had intended to return 5 and forgot.
Thanks for your input, but we find it very useful to
allow return with values in functions with named
returns. The names are good documentation,
and the values make it clear what exactly is
being returned. We've written a lot of Go code
using this style and are quite happy with it.
by thwilloch:
The text was updated successfully, but these errors were encountered: