Slide 12
Slide 12 text
SWITCH to WHEN
Java Kotlin
• Direct assignment to variable as an result of when closure
if (fragment instanceof HomeFragment) {
// Logic here
}
val view = when (viewType) {
1 -> layoutInflater.inflate(R.layout.item_pax_checkbox, parent, false)
else -> layoutInflater.inflate(R.layout.item_pax_type, parent, false)
}
when(fragment) {
is HomeFragment -> {
}
}