Named return variables are available within the scope of the function. Consider the following funciton
func SomeFunc() (foo int, bar int) {
// notice how foo and bar is already defined in the body and a return w/no arg returns those values
foo = 10
bar = 20
return // compiler knows it has to return foo & bar
)
2. Type Assertion (ala dynamic_cast)
Given an interface type, it can be coerced to another interface type (at runtime) provided the underlying type supports both the interfaces
Look for type assertion here (Go For C++ Programmers). You have to scroll down to the relevant section. Just use browser search - use type assertion
3. defer - a piece of code to run when the surrounding function returns. Cool feature! See Here
4. dot import
Import declaration Local name of Sin
import . "lib/math" Sin (as opposed to math.Sin)
See go-doc - import
No comments:
Post a Comment