4 ms·
The := both declares a new variable by an inferred type and assigns a value to it. Explicitly, this would be the same as var item *Item = item It creates a
by _ikke_ 4y ago
The := both declares a new variable by an inferred type and assigns a value to it. Explicitly, this would be the same as
var item *Item = item
It creates a locally scoped variable that shadows the existing one.
- colonwqbang 4y agoAh ok, so different name resolution rules apply on the left and right sides of the operator? On the left side, "item" resolves to the "item" in inner scope (that is declared on the same line). On the right side it resolves to the "item" in outer scope. Then I understand what's happening though I'm still not convinced it's sane behaviour. I would expect all identical names in a single scope to refer to the same variable.
- deleted 4y ago[deleted]