mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 14:18:20 +08:00 
			
		
		
		
	function PrintMap supports Generics
This commit is contained in:
		@ -97,9 +97,9 @@ func showTrunk(t *trunk) {
 | 
				
			|||||||
	fmt.Print(t.str)
 | 
						fmt.Print(t.str)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PrintHashMap Print a hash map
 | 
					// PrintMap Print a hash map
 | 
				
			||||||
func PrintMap(m map[int]string) {
 | 
					func PrintMap[K comparable, V any](m map[K]V) {
 | 
				
			||||||
	for key, value := range m {
 | 
						for key, value := range m {
 | 
				
			||||||
		fmt.Printf("%d -> %s\n", key, value)
 | 
							fmt.Println(key, "->", value)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user