Mohamed Ibrahim
07/09/2019, 1:05 PMwhen
is the right choice .. what I need to achieve something like this
when ( lang ) {
equalIgnoreCase "AR" -> "Arabic"
equalIgnoreCase "EN" -> "English"
equalIgnoreCase "RU" -> "Russian"
}
max
07/09/2019, 1:09 PMwhen {
lang.equals("AR", true) -> "Arabic"
}
wbertan
07/09/2019, 1:09 PMprivate fun String.expandName(): String =
when {
this.equals("AR", true) -> "Arabic"
this.equals("EN", true) -> "English"
this.equals("RU", true) -> "Russian"
else -> this
}
@Test
fun asas() {
val value: String = "AR"
assertEquals("Arabic", value.expandName())
}
Mohamed Ibrahim
07/09/2019, 1:11 PMgildor
07/09/2019, 1:29 PMwhen(lang.toUpperCase()) {
"AR" -> "Arabic"
}
Ryan Mentley
07/09/2019, 11:23 PMlang.toUpperCase(<http://Locale.US|Locale.US>)
unless you enjoy surprising behavior in other locales 🙂gildor
07/09/2019, 11:26 PM