Anyone familiar with C/C++ will be familiar with the current convention of
using an asterisk to indicate a pointer to the value. Yes, there is a
reasonable argument for using an ampersand but either syntax is essentially
arbitrary; thus a coin flip as to which to use. So we might as well use the
C convention which a lot of programmers are familiar with rather than using
the alternative.

On Tue, Mar 5, 2024 at 8:33 PM Matheus Fassis Corocher <
matheuscoroc...@gmail.com> wrote:

> I was studying about pointers and struct in Golang and one thing that I
> don't understand is why using * in return of signature of function instead
> of & if the return of function is an address of variable?
>
> The correct version that works:
>
> func NewVertex(X, Y int) **Vertex* {
>   ...
>   return &Vertex{X, Y}
> }
>
> The version in my mind should be correct:
>
> func NewVertex(X, Y int) *&Vertex* {
>   ...
>   return &Vertex{X, Y}
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/9c60ff1f-6ddb-4136-bfab-642c102a47c7n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/9c60ff1f-6ddb-4136-bfab-642c102a47c7n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_-f52w2FC9i%3DSgBeyjvpn4m8BohmBHK169rC3TTBo-QQ%40mail.gmail.com.

Reply via email to