Is there a short hand for accessing x.Bar[0] in the following case?
The direct attempt results in (type *[]string does not support indexing) for obvious reasons
type A struct {
B *[]string
}
x := &Foo{Bar: &[]string{"1", "2"}}
Is there a short hand for accessing x.Bar[0] in the following case?
The direct attempt results in (type *[]string does not support indexing) for obvious reasons
type A struct {
B *[]string
}
x := &Foo{Bar: &[]string{"1", "2"}}
It would be
(*x.Bar)[0]
You use parentheses to change the precedence of operators: [] has a higher precedence than *.