scala import com.github.andrewoma.dexx.collection.List val nums = List.of(1, 2, 3, 4, 5) val squares = nums.map(x => x * x) val filtered = squares.filter(x => x % 2 == 0) scala import com.github.andrewoma.dexx.collection.HashSet val set1 = HashSet.of(1, 2, 3, 4) val set2 = HashSet.of(3, 4, 5, 6) val intersect = set1.intersect(set2) val union = set1.union(set2) scala import com.github.andrewoma.dexx.collection.HashMap val map = HashMap.empty[String, Int] val updatedMap = map.put("key1", 1).put("key2", 2) val value = updatedMap.get("key1") val keys = updatedMap.keys scala import com.github.andrewoma.dexx.collection.IndexedSeq val range = IndexedSeq.range(1, 10) val squares = range.map(x => x * x) val even = range.filter(x => x % 2 == 0) sbt libraryDependencies += "com.github.andrewoma.dexx" %% "dexx-collections" % "0.8" scala import com.github.andrewoma.dexx.collection.{List, Set, Map, IndexedSeq} import com.github.andrewoma.dexx.collection.mutable.{HashSet, HashMap} import com.github.andrewoma.dexx.collection.extensions._


上一篇:
下一篇:
切换中文