IntMap 在无害映射后改变类型
考虑这段代码:
Welcome to Scala version 2.8.0.r0-b20100714201327 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
scala> val a = IntMap((1,1))
a: scala.collection.immutable.IntMap[Int] = IntMap((1,1))
scala> a.map(x => (x._1,x._2 + 1))
res23: scala.collection.immutable.Map[Int,Int] = Map((1,2))
header of IntMap.map says this def map [B] (f: ((Int, T)) ⇒ B) : immutable.IntMap[B]
[use case] Builds a new collection by applying a function to all elements of this immutable integer map.How should I construct the lambda to return IntMap?
consider this piece of code:
Welcome to Scala version 2.8.0.r0-b20100714201327 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
scala> val a = IntMap((1,1))
a: scala.collection.immutable.IntMap[Int] = IntMap((1,1))
scala> a.map(x => (x._1,x._2 + 1))
res23: scala.collection.immutable.Map[Int,Int] = Map((1,2))
header of IntMap.map says this
def map [B] (f: ((Int, T)) ⇒ B) : immutable.IntMap[B]
[use case] Builds a new collection by applying a function to all elements
of this immutable integer map.
How should I construct the lambda to return IntMap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Scala 2.8 下,我得到
Under Scala 2.8, I get