‘append’
method is used to append an element to a slice.
Example
var vowels
= []string{"a", "e", "i"}
vowels =
append(vowels, "o")
App.go
package main import "fmt" func main() { var vowels = []string{"a", "e", "i"} vowels = append(vowels, "o") vowels = append(vowels, "u") fmt.Println(vowels) }
Output
[a e i o
u]
No comments:
Post a Comment