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 230 views
1 answer 239 views
1 answer 250 views
1 answer 264 views
1 answer 203 views
203 views asked Sep 15, 2020 by avibootz
3 answers 287 views
287 views asked May 24, 2020 by avibootz
1 answer 189 views
189 views asked Feb 28, 2020 by avibootz
...