for the first attempt (marked gray): ```Elvis oper...
# android
o
for the first attempt (marked gray):
Copy code
Elvis operator always returns the left operand of non-nullable String
for the 2nd attempt (marked yellow):
Copy code
condition currentUser?.office?.name.toString() is always 'true'
Why is that not possible to be null?
k
if you call .toString() on a null object, you will end up with a “null” as string and not
null
. You should have
…name?.toString()
👍 1
☝️ 1
🍻 1
o
what the
,
does?
k
oh, sorry, that should be a dot.
o
Ohhhhh brilliant, thank you my friend 😄 issue fixed
What about when using formatted strings inside the strings.xml? For example, I use the following:
Copy code
<string name="main_profile_lawyer_title">עו"ד %1$s %2$s</string>
Copy code
fpTitleTextView.text = getString(R.string.main_profile_lawyer_title,currentUser?.firstName, currentUser?.lastName) ?: "SOME DEFAULT STRING"
The elvis for “SOME DEFAULT STRING” is grayed out.