News for hackers. Stuff that matters.
Re:Go says Wat by randomdata on Friday September 07, 2018 @11:36PM (#17939256)
> This prints 1234 and 1234 as you'd expect.

Until it doesn't.

  type thing struct {
  	foo *int
  }

  func f(x thing) {
  	*x.foo = 42
  }

  func main() {
  	v := 1234
  	var x thing
  	x.foo = &v
  	fmt.Printf("x.foo before: %v\n", *x.foo)
  	f(x)
  	fmt.Printf("x.foo after: %v\n", *x.foo)
  }
Or maybe that is what you'd expect, but then slices shouldn't seem so mysterious.

There are no comments on this comment yet.