Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wow, I'm not really interested in learning Go, but I was drawn in and made it all the way to learnInterfaces. Congrats!

One question: why have named return values (in learnMemory) if you return something different? If you didn't have a return statement at all, would the function return the final value of p and q?



>why have named return values (in learnMemory) if you return something different?

Probably to avoid declaring the function as `func learnMemory() (int, int)`.

>If you didn't have a return statement at all, would the function return the final value of p and q?

No, you have to do that explicitly. You can do `return`, though, which will return the variables whose names match the definition.


  > One question: why have named return values (in learnMemory) if you return something different? If you didn't have a return statement at all, would the function return the final value of p and q?
Kinda. You still have a return statement, but you may omit the arguments. See: http://golang.org/doc/effective_go.html#named-results


To describe what you are returning. An int tells you a lot less than status404s int.


Because the variable are already declared and ready to be used. Difference can be seen here → http://play.golang.org/p/IVPiw_2Uph




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: