‘len’
function return number of items in a map.
App.go
package main import "fmt" func main() { employees := map[int]string{ 1: "Krishna", 2: "Ram", //Must have trailing comma } fmt.Println("Map with two elements : ", employees) fmt.Println("Total number of Items : ", len(employees)) }
Output
Map with
two elements : map[1:Krishna 2:Ram]
Total
number of Items : 2
No comments:
Post a Comment