Skip to content

Commit 4b7dc2b

Browse files
Make and Append operation
Make and Append operation in slice beginner program
1 parent 700550e commit 4b7dc2b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

beginner/slice.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ import (
99
func main() {
1010
var str string = "Lorem ipsum dolor sit amet"
1111
fmt.Println(str[6:11])
12+
13+
//Make a new slice using make
14+
s := make([]string, 3)
15+
16+
//Appending elements to existing slice
17+
s = append(s, "abc")
18+
fmt.Println(s)
1219
}

0 commit comments

Comments
 (0)