This is a shallow, visual symmetry.
Per Go spec, Foo{} and 5 are not related in a meaningful way.
Foo{} denotes a runtime operation that creates a new instance of Foo
struct, and & takes an address of this instance.
5 is an integer literal https://golang.org/ref/spec#Integer_literals. While
i
> 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.
I've never understood the reason for this limitation. I'd expect the
compiler to box any value
On Mon, Feb 26, 2018 at 10:01 PM, wrote:
> or similar simpler example :
>
> this works :
>
> var j int = 42
> var p *int
> p=&j // this works
> fmt.Println(*p)
>
>
>
> var j int = 42
> var p *int
> p=&int(j) //this doesn't work
> fmt.Print
Thank you Sir
2018. február 27., kedd 5:56:57 UTC+1 időpontban k1at...@gmail.com a
következőt írta:
>
> Hi
>
> I have seen this example somewhere but i modified it :
>
> package main
>
> import "fmt"
>
> type notifier interface {
> notify()
> }
>
> type duration int
>
> func (d *duration) notif
On Tue, Feb 27, 2018 at 4:01 PM, 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 doe
or similar simpler example :
this works :
var j int = 42
var p *int
p=&j // this works
fmt.Println(*p)
var j int = 42
var p *int
p=&int(j) //this doesn't work
fmt.Println(*p)
2018. február 27., kedd 5:56:57 UTC+1 időpontban k1at..