scala 2.8 breakout
Posted
by oxbow_lakes
on Stack Overflow
See other posts from Stack Overflow
or by oxbow_lakes
Published on 2009-11-11T14:53:23Z
Indexed on
2010/05/08
15:08 UTC
Read the original article
Hit count: 247
In Scala 2.8, there is an object in scala.collection.package.scala
:
def breakOut[From, T, To](implicit b : CanBuildFrom[Nothing, T, To]) =
new CanBuildFrom[From, T, To] {
def apply(from: From) = b.apply() ; def apply() = b.apply()
}
I have been told that this results in:
> import scala.collection.breakOut
> val map : Map[Int,String] = List("London", "Paris").map(x => (x.length, x))(breakOut)
map: Map[Int,String] = Map(6 -> London, 5 -> Paris)
What is going on here? Why is breakOut
being called as an argument to my List
?
© Stack Overflow or respective owner