Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created August 6, 2019 12:26
Show Gist options
  • Save kmizu/cacdb74ca6b55803548c283d62a819f3 to your computer and use it in GitHub Desktop.
Save kmizu/cacdb74ca6b55803548c283d62a819f3 to your computer and use it in GitHub Desktop.
object StringLiteralType {
def isAType(arg: String): Unit = arg match {
case _ : "a" => println("This is `a` type")
case _ => println("not `a`")
}
def a1 = isAType("a")
def a2 = isAType(new String("a"))
def a3 = new String("a").isInstanceOf["a"]
def main(args: Array[String]): Unit = {
println(a1)
println(a2)
println(a3)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment