scala - What does the ++: operator do to a list? -
alright, scala has me feeling pretty dense. i'm finding docs pretty impenetrable -- , worse, can't google term "scala ++:" because google drops operator terms!
i reading code , saw line:
seq(file) ++: children.flatmap(walktree(_)) but couldn't figure out. docs seq show 3 things:
++ ++: ++: where latter 2 on loaded do.. something. actual explanation in doc says same thing ++. namely, add together 1 list another.
so, difference between operators..?
++ , ++: homecoming different results when operands different types of collection. ++ returns same collection type left side, , ++: returns same collection type right side:
scala> list(5) ++ vector(5) res2: list[int] = list(5, 5) scala> list(5) ++: vector(5) res3: scala.collection.immutable.vector[int] = vector(5, 5) there 2 overloaded versions of ++: solely implementation reasons. ++: needs able take traversableonce, overloaded version provided traversable (a subtype of traversableonce) efficiency.
scala
No comments:
Post a Comment