andym
09/27/2019, 3:01 PMkarelpeeters
09/27/2019, 3:04 PMandym
09/27/2019, 3:17 PMinline class LanguageCodeString(val code: String) {
fun getDisplayName(context: Context): String =
when {
Languages.ENGLISH.equals(code, true) -> context.getString(R.string.english_info_label)
Languages.FRENCH.equals(code, true) -> context.getString(R.string.french_info_label)
else -> code
}
}
val language: LanguageCodeString =
someNullableString?.let { LanguageCodeString(it) }
?: LanguageCodeString("")
// ...
processStuff(arg1, arg2, arg3, language, arg4)
// ...
private fun processStuff(
context: Context,
arg1: String? = "",
arg2: String? = "",
arg3: String? = "",
language: LanguageCodeString = LanguageCodeString(""),
arg4: String? = ""
) {
// ...
formatted.add(language.getDisplayName(context))
}
localObject1 = someNullableString.getLanguage();
String str3;
if (localObject1 != null)
{
str3 = LanguageCodeString.constructor-impl((String)localObject1);
if (str3 != null) {}
}
else
{
str3 = LanguageCodeString.constructor-impl("");
}
I saw the constructor call, but didn’t notice str3
is a Stringconstructor-impl()
to do the null check