Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutating map #8

Open
kevinyan815 opened this issue Aug 8, 2019 · 0 comments
Open

Mutating map #8

kevinyan815 opened this issue Aug 8, 2019 · 0 comments

Comments

@kevinyan815
Copy link
Owner

kevinyan815 commented Aug 8, 2019

  • 插入或者更新map m的元素
m[key] = elem
  • 读取mkey对应的元素
elem = m[key]
  • m中删除key对应的元素
delete(m, key)
  • 测试keym中是否存在
elem, ok = m[key]

如果keym中,ok的值为trueelem为对应map元素类型的值。否则okfalseelem为对应map元素类型的零值。

Note: 如果elemok未定义可以用短标记的形式赋值

elem, ok := m[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant