So, in java we have a ternary operator (?), Which is sometimes useful for easy some value calculated using if-else lines. For example:
myAdapter.setAdapterItems( textToSearch.length == 0 ? noteList : noteList.sublist(0, length-5) )
I know the equivalent in kotlin would be:
myAdapter.setAdapterItems( if(textToSearch.length == 0) noteList else noteList.sublist(0, length-5) )
But I just loved the ternary operator in Java, for short expression conditions and when passing values ββto a method. Is there an equivalent to Kotlin?
ternary-operator kotlin
johnny_crq
source share