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 9794342 commit ef7a7ffCopy full SHA for ef7a7ff
codes/ch6_slices/create-a-slices.go
@@ -0,0 +1,23 @@
1
+package main
2
+
3
+func main() {
4
5
+ /**
6
+ * Blank [] will declare a slices.
7
+ * If you provide size like [5] will declare an array.
8
+ */
9
+ var employee []string
10
11
12
+ * Initialize a slices with type, length and capacity.
13
+ * length is required field.
14
+ *
15
+ * make([]string, length, [capacity])
16
17
+ employee = make([]string, 3)
18
19
+ employee[0] = "Ashwin"
20
+ employee[1] = "Kumar"
21
+ employee[2] = "Saju"
22
+ // employee[3] = "Ajay" // This will throw an error `out of range`
23
+}
0 commit comments