coco icon indicating copy to clipboard operation
coco copied to clipboard

Modifying a non-pointer receiver in example

Open ghost opened this issue 6 years ago • 1 comments

https://github.com/mrmiguu/coco/blob/e51861ba64cb68c40c4abda2cce111872c47fd30/example/Count.go#L19

The example is modifying a non-pointer receiver's field. It seems like a bug.

ghost avatar Mar 11 '19 08:03 ghost

The aim here was to simulate a sort of top-down functional approach similar to React in how it accesses state at a field-level but mutates it indirectly:

this.setState({ Cocos: [...this.state.Cocos, '🥥'] })

But I'm more than open to considering a pointer style of mutation that is more Vue-like and 2-way bound. That might even feel more idiomatic in Go. Thanks for pointing this out!

mrmiguu avatar Mar 11 '19 15:03 mrmiguu