 
              エントリーの編集
 
                エントリーの編集は全ユーザーに共通の機能です。
                    必ずガイドラインを一読の上ご利用ください。
Scala best way of turning a Collection into a Map-by-key?
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
 
          - バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Scala best way of turning a Collection into a Map-by-key?
If I have a collection c of type T and there is a property p on T (of type P, say), what is the b... If I have a collection c of type T and there is a property p on T (of type P, say), what is the best way to do a map-by-extracting-key? val c: Collection[T] val m: Map[P, T] One way is the following: m = new HashMap[P, T] c foreach { t => m add (t.getP, t) } But now I need a mutable map. Is there a better way of doing this so that it's in 1 line and I end up with an immutable Map? (Obviously I cou
 
               
             
 
 
 

