Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用以下方法将 Future[Seq[(String, String)]] 转换为 Future[Seq[(String)]]:
sortedSeq.map(_._2)
所以 sortedSeq 的类型是 Future[Seq[(String, String)]]
但我不断收到错误:
value _2 is not a member of Seq[(String, String)]
我究竟做错了什么 ?
sortedSeq.map 会将映射应用到 Future,但您希望它应用到未来内 Seq 的元素。
所以像:
sortedSeq.map(_.map(_._2))
所以你在未来映射 Seq 的内容。
如果您有一个生成此代码示例来尝试它可能会更容易。