Array: size cố định, value type [5]int.
- Slice: dynamic, reference type
[]int. - Slice dùng phổ biến hơn.
make([]int, 0, 10)tạo slice capacity 10.append(slice, item)thêm phần tử. - Slice là view lên underlying array.
Arrays have a fixed size and are value types: [5]int.
- Slices are dynamic and are reference types:
[]int. - Slices are used far more often.
make([]int, 0, 10)creates a slice with capacity 10.append(slice, item)adds an element. - A slice is a view over an underlying array.