Inde 0, Size 0 when selection : I create a selection condition inside looping , when data true it will be add into an array, false also. Then i create another selection condition outside the looping process to get the array. then when the looping get true data it will do some true stuff, if false will do some false stuff. But i got error when i create these condition. I try many case but still can't work for me. Here is my code. Anyone please help.

    val arrayTrue = ArrayList<String?>()
    val arrayFalse = ArrayList<String?>()

    for (i in 0 until response.body()!!.size) {
      if (response.body()?.get(i)?.custNoktp == child.custNoktp == true) {

          arrayTrue.add("1")

      }else if (response.body()?.get(i)?.custNoktp == child.custNoktp == false){

          arrayFalse.add("0")

      }
    }


    if(arrayTrue.get(0).equals("1")){
         progressDialog.setMessage("True...")
         progressDialog.show()

         //do stuff here

    }else if (arrayTrue.isEmpty()== true){
                              
        progressDialog.setMessage("False...")
        progressDialog.show()

        //do stuff here
    }


I have try this one but still get the same error.

    if(arrayTrue.get(0).equals("1")){
     progressDialog.setMessage("True...")
     progressDialog.show()

     //do stuff here

    }else if (arrayFalse.equals("0")){

    progressDialog.setMessage("False...")
    progressDialog.show()

    //do stuff here
    }

                                




