what is the difference between ```var tmp *string``` and ```tmp := new(string)```
what is the difference between
and
var tmp *string
and
tmp := new(string)
No any search results
You already invited:
2 Answers
leo
Upvotes from:
except you're creating a pointer on the first one and a value on the second one - you could have done `tmp := new(*string)` and they would have been functionally identically (both `nil`)
that being said, I never do the `new(variable)` thing
Brian
Upvotes from:
`var tmp *string` is just declaration so no memory allotted, whereas in `new(string(` its declared and initialised, so you could print the value too. (edited)