dpgbh20688 2014-08-13 07:20
浏览 19
已采纳

为什么地图不返回其值?

I have a function which simply returns the value of a map. However for some reasons it doesn't do that. Any idea why ? I've pasted here the code. You may also play it using

Try it!

package main

import "fmt"

func main() {    
    a := CountryCode("Australia")    
    fmt.Println(a)    
}

func CountryCode(s string) string {    
    m := make(map[string]string)
    // [snip]
    m["AU"] = "Australia"
    // [snip]
    return m[s]
}

func CodeByCountry(s string) string {
    m := make(map[string]string)
    // [snip]
    m["Australia"] = "AU"
    // [snip]
    return m[s]
}
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 如何按照企业名字进行爬虫
      • ¥15 关于#单片机#的问题,如何解决?
      • ¥100 制作短链接和api接口的
      • ¥15 星河亮点sp9500测试指导
      • ¥15 dataframe 某列数据分列
      • ¥15 风扇导入fluent后仿真压力和速度数据卡在旋转域
      • ¥15 echarts中dataZoom报错
      • ¥15 求解答:《前端综合基础》作为一门课程的话,应该包含哪些内容?
      • ¥15 软件原型系统开发+实例测试
      • ¥50 C#上位机调试Win USB