Skip to content

Instantly share code, notes, and snippets.

@rafakob
Created December 1, 2017 11:35
Show Gist options
  • Save rafakob/f0d49f044f91a908d69ec351ed91526c to your computer and use it in GitHub Desktop.
Save rafakob/f0d49f044f91a908d69ec351ed91526c to your computer and use it in GitHub Desktop.
Kotlin - casting
Condition Result
"test" is String true
"test" is String? true
null is String false
null is String? true
"test" as String ok
"test" as String? ok
123 as String throw
123 as String? throw
null as String throw
null as String? returns null
null as? String returns null
null as? String? returns null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment