Skip to content

Instantly share code, notes, and snippets.

@naveensrinivasan
Created June 5, 2013 15:25
Show Gist options
  • Save naveensrinivasan/5714723 to your computer and use it in GitHub Desktop.
Save naveensrinivasan/5714723 to your computer and use it in GitHub Desktop.
Sometimes wish that I could add a function to unnamed type using interface{}
func (i interface{}) PLusOne() interface{} {
if w, ok := i.(int); ok {
return w + 1
} else {
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment