Hey guys, can some one please tell me what is this...
# android
o
Hey guys, can some one please tell me what is this “@addOnCompleteListener” returned here? I searched for “kotlin @” and kotlin annotations, but it seems not to be what is in this code. How is it called? (marked in red square). Please ignore the red arrow for now, this is a different question
b
It's telling it to return to that point in the code, 4 lines up has the addCompletionListener. So it will exit out of the listener
If you have nested things you sometimes need to be specific about which return
v
To return from addOnCompleteListener lambda, you specify its name explicitly. If you type just
return
, it will return from the
createUser
function.
a
o
thanks guys @Ben Abramovitch @Vsevolod Kaganovych I still don’t get something. If I remove the @addCompleteListener, I get a compilation error anyway. Why do I need to explicitly mention it then?
a
It is called returns at label
🍕 1
🍻 1
o
thanks! this is exactly what I looked for @Anastasia Finogenova
s
Ofir, this is why the @ is required. If the method you are calling is
inline
, you have the option to either return from the lambda (what you are trying to do), or, like Vsevolod said, return from
f()
. Since the method you are calling is not inlined, you cannot return
f()
from inside the lambda, but you still must declare it properly, so that if
addOnCompleteListener
ever becomes an
inline
method - your implementation won’t break.
o
@StavFX Toda gever, I get it now 🙂, shabat shalom!
😎 2
🇮🇱 1