Advertisement
Guest User

Untitled

a guest
Jul 7th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.39 KB | None | 0 0
  1. import collection.generic.CanBuildFrom
  2. import collection.breakOut
  3.  
  4. class Build[To[_]] {
  5.   def apply[From, T]()(implicit b: CanBuildFrom[Nothing,T,To[T]]): CanBuildFrom[From,T,To[T]] = collection.breakOut
  6. }
  7.  
  8. def build[To[_]] = new Build[To]
  9.  
  10. List(1, 2, 3).map{i => (i * 2, i / 2.0, i.toString)}(build[Array]())
  11. //res0: Array[(Int, Double, String)] = Array((2,0.5,1), (4,1.0,2), (6,1.5,3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement