Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,037 questions

40,897 answers

573 users

How to append values from map to empty slice in Go

1 Answer

0 votes
package main
  
import "fmt"
  
func main() {
    var mp = map[string]int{"go":35,"php":4, "c++":120, "python":8432}
     
    values_slice := []int{}
    for _, value := range mp {
        values_slice = append(values_slice, value)
    }

    fmt.Println(values_slice)
}
  
  
  
  
/*
run:
  
[4 120 8432 35]
  
*/

 





answered Nov 4, 2020 by avibootz

Related questions

1 answer 104 views
2 answers 55 views
1 answer 127 views
1 answer 103 views
103 views asked Sep 15, 2020 by avibootz
1 answer 70 views
70 views asked Aug 9, 2020 by avibootz
...