No. These are variable declarations not assignment statements.

In the assignment “a = b” there is a copy implied but for the variable
declaration the “=“ should not be read as “is copied to” but rather “of
this kind”.

var a is of the kind [3]bytes which happen to be 2, 4, and 6.

Size = 3

Second is similar

var b is of the kind [as many as initializers]bytes which happen to be 2,
4, and 6, so three bytes.

Size = 3

On Thu, Jan 31, 2019 at 4:48 PM 伊藤和也 <kazya.ito.dr...@gmail.com> wrote:

> 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 golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 

*Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>*

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to