Created
June 12, 2020 21:57
-
-
Save monkrus/70529ab098775f7d9364d41a806537cd to your computer and use it in GitHub Desktop.
Type Assertions
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
| package main | |
| import "fmt" | |
| type Developer interface { | |
| Develop() | |
| } | |
| type FrontEnd struct { | |
| Name string | |
| } | |
| type BackEnd struct { | |
| Name string | |
| } | |
| func (b FrontEnd) Develop() { | |
| fmt.Printf("%s develops the frontend\n", b.Name) | |
| } | |
| func (b BackEnd) Develop() { | |
| fmt.Printf("%s develops the backend\n", b.Name) | |
| } | |
| func main() { | |
| var developer2 FrontEnd | |
| developer2.Name = "Evgeny" | |
| developer2.Develop() | |
| var developer BackEnd | |
| developer.Name = "Sergei" | |
| developer.Develop() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment