Arrays & Slices (Append, Make, Copy & Slicing) - Go Tutorial for Beginners #9
6views
008:52
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Master Go's collection types - Arrays and Slices!
In this lesson, you will learn:
✓ Fixed-size arrays and their value semantics
✓ Dynamic slices and reference behavior
✓ Slicing with colon notation
✓ Append and make functions
✓ Copy for independent slices
✓ Nil vs empty slices
⏱️ Timestamps:
0:00 - Introduction
0:24 - Arrays (Fixed Size)
2:09 - Slices (Dynamic)
3:46 - Append and Make
5:38 - Copy and Nil Slices
7:27 - Recap
7:57 - End
💻 Source Code: https://github.com/GoCelesteAI/go_slices
📝 Code Highlights:
// Array (fixed size, value type)
var arr [5]int
fruits := [3]string{"apple", "banana", "cherry"}
// Slice (dynamic, reference type)
nums := []int{10, 20, 30, 40, 50}
fmt.Println(nums[:3]) // First 3
fmt.Println(nums[2:]) // From index 2
// Append
nums = append(nums, 60, 70)
nums = append(nums, more...)
// Make with length and capacity
buffer := make([]int, 5, 10)
// Copy (creates independent slice)
dst := make([]int, len(src))
copy(dst, src)
📺 Previous: Lesson 8 - Loops: for
📺 Next: Lesson 10 - Maps
#Go #Golang #GoTutorial #LearnGo #Programming #Arrays #Slices #GoProgramming