79284313

Date: 2024-12-16 10:21:08
Score: 0.5
Natty:
Report link

In order to get the best out of "slices" and use them properly, we need to have a good grasp of the internals of them. They're composed of three machine words:

  1. A pointer to the backing array,
  2. Current length of slice,
  3. Capacity of the backing array.

slice header

These three items together form what's called Slice Header. When you pass a slice as an argument to a function, you are actually passing a copy of this header. Therefore whatever change done on the copy of this header, is not visible to the original slice created at the main function and it remains intact.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: NeverQuit