I'm new to kotlin and I don't know English well so "Google Translate hello!". I want to return the values that I received during the execution of the if condition. This function iterates through the columns in the excel table until it finds the one I need and returns its number
I tried to write return@getTableValue to indicate where to return the value, but it didn't give anything, I don't understand, help
My code:
private fun getTableValue(xlWs: Sheet, groupe: String, dopgroupe: String): Int { var gr: String var cellNumb: Int var res: Int for (i in 0..20){ gr = xlWs.getRow(0).getCell(i).toString() if (gr == groupe){ cellNumb = i if (dopgroupe == "1") { res = cellNumb } if (dopgroupe == "2") { res = cellNumb + 2 } } } return res // Error Variable 'res' must be initialized }