是否可以在Scala中並行分配元組成員。如果不是有另一種技術來完成類似的東西?Scala:元組的並行賦值
val players = List(
new Player("Django Reinhardt", 42),
new Player("Sol Hoopii", 57),
new Player("Marc Ribot", 64)
)
val winners, losers = players.partition(p => p.score > 50)
// winners = List(Player name:Sol Hoopii score: 57, Player name:Marc Ribot score: 64)
// losers = List(Player name:Django Reinhardt score: 42)
如果你不知道你可以使用簡短的表示法:players.partition(_。score> 50) – Schildmeijer 2010-02-05 16:52:40