Skip to content

Instantly share code, notes, and snippets.

@mattknox
Created November 12, 2014 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattknox/85f3e9e68772b145c6f5 to your computer and use it in GitHub Desktop.
Save mattknox/85f3e9e68772b145c6f5 to your computer and use it in GitHub Desktop.
// candidate syntax for a go-like language with less boilerplate around error return
func doStuff() (string, error) {
var err error
returnOn err, func() { return nil, err } // return the result of calling func if variable is ever non-nil
thing1, err := possiblyFailingCall()
thing2, err := possiblyFailingCall(thing1)
thing3, err := possiblyFailingCall(thing2)
thing4, err := possiblyFailingCall(thing3)
return thing4, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment