3 ms·
The first one could be mitigated by providing an array of article pointers ([]*Article). That way, article.legs = 99 would work. Else, the way mentioned in the
by ernsheong 9y ago
The first one could be mitigated by providing an array of article pointers ([]*Article). That way, article.legs = 99 would work.
Else, the way mentioned in the article, or (&article).legs =
99 (ugly) would work. Take your pick.
- roskilli 9y ago(&article).legs = 99 This would not work actually because it would only be modifying the copy that exists in the inner loop of the for loop. You'd be taking a pointer to the for loop stack variable and modifying it. If they were already references as you first mention that way simply article.legs = 99 would work yes.
- ernsheong 9y agoThanks for pointing it out.