Monday, 17 August 2015

Basic Go: Return values and Result

Named return values

Go's return values may be named and act just like variables.
These names should be used to document the meaning of the return values.
A return statement without arguments returns the current values of the results. This is known as a "naked" return.
Naked return statements should be used only in short functions, as with the example shown here. They can harm readability in longer functions.


Multiple results

A function can return any number of results.
The swap function returns two strings.


Do comment if it Worked/Not Worked for you.

No comments:

Post a Comment