// Optional listener
listenerInterface?.notifyOfSomething()
// `elvis operator` ?: allows for default value
val likeCount = comment?.likes ?: 0
// Smart Cast
if(user != null) {
user.foo() // compiler knows user isn't null, `?` isn't needed
} else {
}
// if-let
user?.let {
it.foo()
}
Created
January 15, 2016 05:04
-
-
Save jacobmoncur/b124d4b401d3ebaf538b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment