On Mon, Sep 24, 2018 at 5:33 AM, Tamás Király <rock8...@gmail.com> wrote: > Hi, > > can anyone explain why the following does not work? > i want to have the return value's address not the method itself. > > package main > > func main() { > //first > addressofstring := &method() > } > > func method() string { > return "value" > } > > https://play.golang.org/p/UbJ7SK0m9w6
You can't take the address of a function call. The Go specification has further explanation of what you can take the address of. https://golang.org/ref/spec#Address_operators The reason you can't take the address of a function call is that it's ambiguous as to what memory location you're getting the address of. By not having this as a feature there doesn't need to be a rule to disambiguate that. -- 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. For more options, visit https://groups.google.com/d/optout.