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 339 views
1 answer 347 views
1 answer 335 views
1 answer 374 views
1 answer 299 views
299 views asked Sep 15, 2020 by avibootz
3 answers 431 views
431 views asked May 24, 2020 by avibootz
1 answer 262 views
262 views asked Feb 28, 2020 by avibootz
...