Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- type person struct {
- firstName string
- lastName string
- contactInfo
- }
- type contactInfo struct {
- email string
- mobileNumber string
- }
- func (p person) print() {
- fmt.Println(p)
- }
- func (p *person) updateName(newFirstName string, newLastName string) {
- (*p).firstName = newFirstName
- (*p).lastName = newLastName
- }
- func main() {
- jon := person{
- firstName: "Jon",
- lastName: "Snow",
- contactInfo: contactInfo{
- email: "kingof@thenorth.com",
- mobileNumber: "1-800-DROGON",
- },
- }
- jon.print()
- jon.updateName("Aegon", "Targaryen")
- jon.print()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement