Answers for "kotlin when with multiple conditions"

3

kotlin filter multiple conditions

for (i in dnsTestViewModel.msList.indices) {
                    Log.println(Log.ASSERT, "PS", "MS :"+ dnsTestViewModel.msList[i])
                    if(dnsTestViewModel.msList[i] != longm) {
                        for (j in 0 until dnsTestViewModel.msList.size - 1 - i) {
                            if (dnsTestViewModel.msList[j] > dnsTestViewModel.msList[j + 1] && dnsTestViewModel.msList[j] > 0 && dnsTestViewModel.msList[j + 1] > 0) {
                                val tempMs = dnsTestViewModel.msList[j]
                                val tempdns = dnsTestViewModel.tempdnsListFirst[j]
                                dnsTestViewModel.msList[j] = dnsTestViewModel.msList[j + 1]
                                dnsTestViewModel.tempdnsListFirst[j] =
                                    dnsTestViewModel.tempdnsListFirst[j + 1]
                                dnsTestViewModel.msList[j + 1] = tempMs
                                dnsTestViewModel.tempdnsListFirst[j + 1] = tempdns
                            }
                        }
                    }
                }
Posted by: Guest on August-17-2021
0

kotlin when with multiple conditions

fun main() {
   val x = 2
   val square = when (x) {
      1 -> {
          println("x == 1")
          1
      }
      2 -> {
          println("x == 2")
          4
      }
      3 -> { 
         println("x == 3")
         9
      }
      else -> {
          println("Not applicable")
          0
      }
   }
   println(square)
}
Posted by: Guest on October-23-2021
0

kotlin when with multiple conditions

fun main() {
   val x = 1
   val square = when (x) {
      1 -> 1
      2 -> 4
      3 -> 9
      else -> 0
   }
   println(square)
}
Posted by: Guest on October-23-2021

Code answers related to "kotlin when with multiple conditions"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language