如何使用值初始化 Scala 不可变哈希图?
在初始化时设置不可变哈希图内容的语法是什么?
例如,如果我愿意对数组进行硬编码,我会写:
val a = 数组(0,1,2,3)
不可变哈希图的类似物是什么(假设我希望它包含 0->1 和 2->3 对)(在 Scala 2.8 中)?
What's the syntax to set immutable hashmap contents on initialization?
For example, if I was willing to hardcode an array, I'd write:
val a = Array (0, 1, 2, 3)
What's the analogue for immutable hashmaps (say I want it to contain 0->1 and 2->3 pairs) (in Scala 2.8)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的意思是这样的吗?
Do you mean something like this?
从集合创建(记住不要有
new
关键字)To create from a collection (remember NOT to have a
new
keyword)