https://kotlinlang.org logo
#android
Title
# android
m

Manjee

02/07/2018, 12:54 AM
val currentUser = mAuth!!.currentUser what means ‘!!’ ??
y

yaakov

02/07/2018, 12:55 AM
Non-null assertion.
m

Manjee

02/07/2018, 12:56 AM
oh i see thank you
m

marcinmoskala

02/07/2018, 5:58 AM
unsafe. It throws error when
mAuth == null
o

orangy

02/07/2018, 8:38 AM
#getting-started
r

rootandy

02/07/2018, 10:06 AM
better use
mAuth?.currentUser
or
Copy code
mAuth?.currentUser?.let { currentUser -> 
     // someLogic
}
a

amatsehor

02/07/2018, 2:52 PM
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

marcinmoskala

02/08/2018, 11:51 AM
@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

amatsehor

02/08/2018, 11:53 AM
Sure, your solution is better
5 Views