2 ms·
> "receiver implict this parameter" The parameter is actually quite explicit (unlike some other languages). It would probably help your write up to talk abou
by gtrubetskoy 10y ago
> "receiver implict this parameter"
The parameter is actually quite explicit (unlike some other languages).
It would probably help your write up to talk about the difference between (using your example):
func (r Rectangle) Area() float64 {
and
func Area(r Rectangle) float64 {
As well as (this is a common rookie mistake):
func (r Rectangle) SetWidth(w float64) {
r.Width = w // does nothing
and
func (r *Rectangle) SetWidth(w float64) {
r.Width = w
- SomeCallMeTim 10y agoYou might want to point to point that (if?) the second example does work? (And that the difference is the *)