Re:Go is Not Python
by singularity2001 on Friday June 23, 2017 @04:13AM
(#14617700)
for a no-goer: will this copy by value?
```
var fred Student
for _, student := range students {
if student.name == "fred" {
fred = student
}
}
```
[ Parent
| on HN ]
Yes. A copy into type `Student` will copy each field, whereas `*Student` only takes the address. (Which would not be a problem if the loop didn't reuse the memory slot for the loop variable.)
Also, indent with two spaces to get code formatting. HN formatting is (sadly) not Markdown.