Advertisement
Guest User

Untitled

a guest
Sep 10th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.44 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. type structA struct {
  6.         state int
  7. }
  8.  
  9. type structB struct {
  10.         state int
  11. }
  12.  
  13. func (s structA) someFunction(arg int) {
  14.         s.state = arg
  15. }
  16.  
  17. func (s *structB) someFunction(arg int) {
  18.         s.state = arg
  19. }
  20.  
  21. func main() {
  22.         a := structA{}
  23.         b := &structB{}
  24.  
  25.         a.someFunction(1)
  26.         b.someFunction(1)
  27.  
  28.         fmt.Println(a.state)
  29.         fmt.Println(b.state)
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement