Created
November 17, 2010 17:11
-
-
Save maiha/703663 to your computer and use it in GitHub Desktop.
ArrayBuffer_vs_ListBuffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
import scala.collection.mutable.ArrayBuffer | |
val elements = List(1,2,3) | |
def map[T](block: Int => T) = { | |
val vals = ArrayBuffer[T]() | |
elements foreach{ i => vals += block(i) } | |
vals.toArray | |
} | |
} | |
// faild (scala-2.8.1) | |
error: could not find implicit value for evidence parameter of type ClassManifest[T] | |
vals.toArray | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
import scala.collection.mutable.ListBuffer | |
val elements = List(1,2,3) | |
def map[T](block: Int => T) = { | |
val vals = ListBuffer[T]() | |
elements foreach{ i => vals += block(i) } | |
vals.toList | |
} | |
} | |
// passed (scala-2.8.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment