特牛网址导航

scala中获取Map中key和value的方法-CSDN博客

网友收藏
文章浏览阅读4.5k次。val scores=Map("Alice"->10,"Bob"->3,"Cindy"->8)// 获取所有的key val nameList=scores.map(_._1)// map 函数返回List println(nameList.getClass)遍历list中的元素 nameList.foreach((x:St..._scala 获取map的key