Last active
October 3, 2021 09:21
-
-
Save mkock/1a0c86ff7e204625a8bbeb18a061a118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| type car struct {} | |
| func (c *car) start() { return } | |
| func (c *car) stop() { return } | |
| type vehicle interface { | |
| start() | |
| stop() | |
| } | |
| func isCar(v vehicle) bool { | |
| _, ok := v.(*car) | |
| return ok | |
| } | |
| func main() { | |
| var v = new(car) | |
| fmt.Println(isCar(v)) // Prints "true" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment