Created
February 11, 2015 15:52
-
-
Save shigemk2/106fec86e083c1755dcd 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
def isType(x: Any): Boolean = x match { | |
case p: String => true | |
case p: Int => true | |
case _ => false | |
} | |
def isType2(x: Any): Boolean = { | |
if (x.isInstanceOf[String]) { | |
return true | |
} else if (x.isInstanceOf[Int]) { | |
return true | |
} else { | |
return false | |
} | |
} | |
println(isType(1)) | |
println(isType(false)) | |
println(isType2(1)) | |
println(isType2(false)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment