• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Odd Description of Variable Assignment

 
Ranch Hand
Posts: 246
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm taking a look at the specification of the Go language at "https://golang.org/ref/spec#Introduction", part way down that page, under the section labeled "Variables", where it says in a greyed box:

Is this saying that variables {v} and {x} have different values? Is the value {nil} different from the value {(*T)(nil)}? I'm not entirely sure what this is saying.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think they're just trying to emphasize that x is dynamically typed to *T -- there doesn't seem to be a difference between nil and (*T)(nil)

I put some code in the playground: https://play.golang.org/p/vVeFnK9Spx

Try playing around with lines 31 and 35 and see which variables work on the right side of the assignment statements and which ones don't.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic