3 ms·
I think Go has exactly C's semantics here. The following is valid syntax with the same semantics in both: array[i] = 9 *pointer = 9 array[i].fieldName =
by simiones 6y ago
I think Go has exactly C's semantics here. The following is valid syntax with the same semantics in both:
array[i] = 9
*pointer = 9
array[i].fieldName = 9
(*pointer).fieldName = 9
structValue.fieldName = 9
pointer->fieldName = 9 // Go equivalent: pointer.fieldName = 9
// you can also create a pointer to any of these lvalues
// in either language with &
Go has some additional syntax in map[key], but that behaves more strangely (it's an lvalue in that you can assign to it - map[key] = value - but you can't create a pointer to it - &(map[key]) is invalid syntax).