So in Go, 
The meaning of "declare" is allocate memory for a variable and initialize 
the variable explicitly or implicitly.
e.g.
var a int = 3   // "a" is explicitly initialized
var b int         // "b" is implicitly initialized

The meaning of "assign" is give a copy of a value to a variable
e.g.
a = 300 // "a" gets the copy of "300"
b = a     // "b" gets the copy of "300" of  "a"

2019年2月1日金曜日 9時48分34秒 UTC+9 伊藤和也:
>
> When initializing variables, If the copies of values are made,  their 
> memory usages will be:
>
> var a = [3]int8{2, 4, 6}
>>        |              |
>
>  3 bytes + 3 bytes = 6 bytes
>
>
> var b = []int8[2, 4, 6}
>>        |               |
>> 24 bytes + 24 bytes = 48 bytes
>
>
> var c = func() {}
>>       |             |
>>  8 bytes + 8 bytes = 16 bytes 
>
>
> var d = struct{n1 int, n2 int}{1, 2}
>>        |                     |
>> 16 bytes   +   16 bytes = 32 bytes
>
>

-- 
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.

Reply via email to