How to append element to slice in Go

1 Answer

0 votes
package main 

import "fmt"
  
func main() {
    arr := []string{"go", "c++", "php", "java"}
	
	fmt.Println(arr)
		
	arr = append(arr, "python")
	
	fmt.Println(arr)
}

  
  
/*
run:
  
[go c++ php java]
[go c++ php java python]

*/

 



answered Aug 9, 2020 by avibootz

Related questions

2 answers 228 views
1 answer 233 views
1 answer 243 views
1 answer 264 views
1 answer 200 views
200 views asked Sep 15, 2020 by avibootz
3 answers 280 views
280 views asked May 24, 2020 by avibootz
1 answer 185 views
185 views asked Feb 28, 2020 by avibootz
...