Go language type: array slice

Source: Internet
Author: User

At first glance, an array slice is like a pointer to an array, and in fact it has its own data structure, not just a pointer. The data structure of an array slice can be abstracted into the following 3 variables:

1. A pointer to a native array;

2. The number of elements in the array slice;

3. The array slice has allocated storage space.

Slice is not a value type, but a reference type, just like a pointer, writing to a slice-made element actually affects the underlying array layer, slice really just a thin layer of operation encapsulation. Thus, slice has an important purpose as a function parameter, which avoids passing the array directly and causing the entire array to have a memory copy.

Go language type: array slice

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.