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 Birds interface { // Distill common methods | |
fly() | |
} | |
type Dove struct { | |
} |
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 Person struct { // abstract field | |
name string | |
} | |
func (p *Person) getName() { // Encapsulation method | |
fmt.Println(p.name) |
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 Person struct { // abstract field | |
name string | |
} | |
func (person *Person) setName(name string) { // Encapsulation method | |
person.name = name |