Home > Back-end >  Kotlin "variable expected" error when doing assignment to Array element
Kotlin "variable expected" error when doing assignment to Array element

Time:03-24

I'm writing the following nested function where dfsVisit uses the arrays "numCaminos" and "colores" declared in the outer function enter image description here

However the kotlin compiler is giving me a "variable expected" error on the assignments in lines 31 and 34 specifically, this error doesn't show up on any of the other Array assignments within the nested dfsVisit function. I tried de-nesting the functions and passing the arrays as arguments of dfsVisit but the problem persisted on those 2 assignments specifically. Why could this be happening?

I'm running the Kotlin compiler in Manjaro Linux through the repository package

Note: Sorry for using a picture instead of a code block, the post editor was giving me some formatting issues.

CodePudding user response:

Just remove !! from the left side of the assignment. It doesn't really make sense there.

  • Related