Last active
November 14, 2016 12:35
-
-
Save Renkai/ddd59337d3c302eb3d061ff8d249413c to your computer and use it in GitHub Desktop.
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
/** | |
* Created by renkai on 16/9/7. | |
*/ | |
object Main2 { | |
def isSingleton[A](a: A)(implicit ev: A <:< Singleton = null) = { | |
Option(ev).isDefined | |
} | |
def isSingleton2[A](a: A) = { | |
isSingleton(a) | |
} | |
def isSingleton3[A](a: A)(implicit ev: A <:< Singleton = null) = { | |
isSingleton(a) | |
} | |
def main(args: Array[String]): Unit = { | |
println("isSingleton(Main2) = " + isSingleton(Main2)) | |
println("isSingleton2(Main2) = " + isSingleton2(Main2)) | |
println("isSingleton3(Main2) = " + isSingleton3(Main2)) | |
// isSingleton(Main2) = true | |
// isSingleton2(Main2) = false | |
// isSingleton3(Main2) = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment