val currentUser = mAuth!!.currentUser what means ...
# android
m
val currentUser = mAuth!!.currentUser what means ‘!!’ ??
y
Non-null assertion.
m
oh i see thank you
m
unsafe. It throws error when
mAuth == null
o
#getting-started
r
better use
mAuth?.currentUser
or
Copy code
mAuth?.currentUser?.let { currentUser -> 
     // someLogic
}
a
And even better with a fallback (sure, if you really need it) mAuth?.currentUser?.let { currentUser -> // someLogic } ?: kotlin.run { // smth if mAuth or currentUser is null }
👍 1
m
@amatsehor You really think it is more readable then this?
Copy code
val user = mAuth?.currentUser
if(user != null) { 
    // someLogic
} else {
    // smth if _mAuth_ or _currentUser_ is _null_
}
a
Sure, your solution is better