Skip to content

Instantly share code, notes, and snippets.

@robey
Created November 27, 2009 05:49
Show Gist options
  • Save robey/243843 to your computer and use it in GitHub Desktop.
Save robey/243843 to your computer and use it in GitHub Desktop.
// allows you to do this (manifest is of type Manifest[T]):
// val obj: T = manifest.create()
implicit def manifest2creator[T](m: Manifest[T]): Creator[T] = new Creator(m)
class Creator[T](m: Manifest[T]) {
def create(): T = m.erasure.newInstance().asInstanceOf[T]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment