Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. type person struct {
  6. firstName string
  7. lastName string
  8. contactInfo
  9. }
  10.  
  11. type contactInfo struct {
  12. email string
  13. mobileNumber string
  14. }
  15.  
  16. func (p person) print() {
  17. fmt.Println(p)
  18. }
  19.  
  20. func (p *person) updateName(newFirstName string, newLastName string) {
  21. (*p).firstName = newFirstName
  22. (*p).lastName = newLastName
  23. }
  24.  
  25. func main() {
  26. jon := person{
  27. firstName: "Jon",
  28. lastName: "Snow",
  29. contactInfo: contactInfo{
  30. email: "kingof@thenorth.com",
  31. mobileNumber: "1-800-DROGON",
  32. },
  33. }
  34.  
  35. jon.print()
  36. jon.updateName("Aegon", "Targaryen")
  37. jon.print()
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement