Skip to content

Instantly share code, notes, and snippets.

@Temidtech
Last active July 1, 2019 09:17
Show Gist options
  • Save Temidtech/3e2b186d0110f3d1990ef169c813d922 to your computer and use it in GitHub Desktop.
Save Temidtech/3e2b186d0110f3d1990ef169c813d922 to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
 val location: Any = "Code must compile!"
 val safeString: String? = location as? String
 val safeFloat: Float? = location as? Float
 println(safeString)
 println(safeFloat)
 }
 
//Compiler returns this output:
  Code must compile!
  null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment