We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2b7634 commit 78996daCopy full SHA for 78996da
codes/ch6_slices/appending-to-slices.go
@@ -0,0 +1,35 @@
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, 3)
20
21
+ employee[0] = "Ashwin"
22
+ employee[1] = "Kumar"
23
+ employee[2] = "Saju"
24
25
+ fmt.Println("Slices: ", employee)
26
27
28
+ * Appending into slices.
29
30
+ employee = append(employee, "Ajay")
31
+ employee = append(employee, "Vinayak")
32
33
+ fmt.Println("After appending: ", employee)
34
35
+}
0 commit comments