Created
October 24, 2012 09:46
-
-
Save yangbajing/3945180 to your computer and use it in GitHub Desktop.
Manifest
This file contains hidden or 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 MakeFoo[A](implicit manifest: Manifest[A]) { | |
| def make: A = manifest.erasure.newInstance.asInstanceOf[A] | |
| private def test { | |
| val r = scala.math.random | |
| } | |
| } | |
| scala> new MakeFoo[java.util.Date] | |
| res1: MakeFoo[java.util.Date] = MakeFoo@18ca1436 | |
| scala> res1.make | |
| res2: java.util.Date = Wed Oct 24 17:47:53 CST 2012 | |
| scala> res1.make | |
| res3: java.util.Date = Wed Oct 24 17:47:56 CST 2012 | |
| scala> res1.make | |
| res4: java.util.Date = Wed Oct 24 17:47:57 CST 2012 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment