Scala Tutorialsを読む 25 Maps
http://scalatutorials.com/tour/interactive_tour_of_scala_maps.html
今日は、Map、写像ですね。
- Maps are constructed simply using Map(key1 -> value1, key2 -> value2, ...)
- Mapは単純にMap(キー1->値1,キー2->値2,...)を使って構築します。
- The Map can contain mixed types, but the final type of the Map keys / values will be the lowest common denominator type
- Mapは型を混ぜて含む事が出来ますが、Mapのキーと値の最終的な型は共通した小限の型になります。
- The default Map is Predef.Map which points to scala.collection.immutable.Map
- デフォルトのMapはPredef.Mapで、scala.collection.immutable.Mapへのリンクです。
- As it currently stands, Map implementation up to size of 4 has a specific class Map1, Map2, - Map3, Map4, beyond that, it uses an immutable HashMap
- 現在、Mapの実装はサイズが4までは特別なMap1,Map2,Map3,Map4のクラスを使い、それ以降は汎用的な書き換え不能なHashMapを使用します。
- You can't have duplicate keys, adding a key value pair whose key already exists, overwrites the value
- キーの集合を複製する事は出来ませんが、キーと値のペアを追加する事で、既に存在しているキーの値を上書きします。
- Order of iteration is not guaranteed to be consistent
- イテレーションの順番は保証されません。
See Also opens in new page 新しいページを開いて参照