Created
March 21, 2014 19:56
-
-
Save vaskoz/9694990 to your computer and use it in GitHub Desktop.
Go Method Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Point struct {} | |
func (p *Point) Scale() { | |
fmt.Println("method") | |
} | |
func Scale(p *Point) { | |
fmt.Println("function") | |
} | |
func main() { | |
p := Point{} | |
ptrA := p.Scale | |
ptrB := Scale | |
fmt.Printf("Type of method Scale is: %T\n", ptrA) | |
fmt.Printf("Type of function Scale is: %T\n", ptrB) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment