File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import "fmt"
4+
5+ func main () {
6+
7+ /**
8+ * Blank [] will declare a slices.
9+ * If you provide size like [5] will declare an array.
10+ */
11+ var employee []string
12+
13+ /**
14+ * Initialize a slices with type, length and capacity.
15+ * length is required field.
16+ *
17+ * make([]string, length, [capacity])
18+ */
19+ employee = make ([]string , 6 )
20+
21+ employee [0 ] = "Ashwin"
22+ employee [1 ] = "Kumar"
23+ employee [2 ] = "Saju"
24+ employee [3 ] = "Ajay"
25+ employee [4 ] = "Vinayak"
26+ employee [5 ] = "Jerin"
27+
28+ fmt .Println ("Slices: " , employee )
29+
30+ // 0:2 - include 0, 1 but excludes 2
31+ // 4: - include last
32+ // ... - expanding slices
33+ employee = append (employee [0 :2 ], employee [4 :]... )
34+
35+ fmt .Println ("After Delete: " , employee )
36+ }
You can’t perform that action at this time.
0 commit comments