Answer the question
In order to leave comments, you need to log in
Why can't I change a field inside a function?
Sorry for the stupid question. Just started to get familiar with Go. There is this code:
package main
import "fmt"
import "math"
type Circle struct {
x int
y int
r float64
}
func circleArea(c *Circle) float64 {
с.r = 10
return math.Pi * c.r * c.r
}
func main() {
c:= Circle{1, 2, 3}
fmt.Println(circleArea(&c))
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question