On Tue, Feb 27, 2018 at 4:01 PM, <[email protected]> wrote: > var j int = 42 > var p *int > p=&int(j) //this doesn't work > fmt.Println(*p) >
Yep, this is true. You can't take the address of the return value of a function or a conversion (which is conceptually just a function) because it doesn't have a location in memory and thus doesn't have an address. If you would like to take the address of a variable containing the value returned from a function you'll need to assign that value to a variable and take the address of that variable. The relevant part of the language spec is https://golang.org/ref/spec#Address_operators - Jesse -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
