100-go-mistakes/06-functions-methods/42-receiver/value/main.go
2021-12-27 15:57:20 +01:00

17 lines
225 B
Go

package main
import "fmt"
type customer struct {
balance float64
}
func (c customer) add(v float64) {
c.balance += v
}
func main() {
c := customer{balance: 100.}
c.add(50.)
fmt.Printf("balance: %.2f\n", c.balance)
}