Home > Software engineering >  unresolved reference error for callable in another Kotlin file
unresolved reference error for callable in another Kotlin file

Time:05-22

I'm new in Kotlin (came from Python) and I'm trying to recreate a tic-tac-toe game.

I'm trying to use a class from another file but i just get this error when i compile the main file:

main.kt:2:21: error: unresolved reference: TicTacToeBoard
    var tabuleiro = TicTacToeBoard()
                    ^

In the directory, called "tictactoe", i have the "main.kt" and "board.kt" files:

The "main.kt" file:

fun main(args: Array<String>) {
    var tabuleiro = TicTacToeBoard()
}

The "board.kt" file:

class TicTacToeBoard

directory with two files and error

The same happens with functions from another file.

I've seen a lot of articles and videos where this same syntax work. What am i missing? why is this not working? and how can i use classes from another file on the main file?

EDIT 1: (more information)

I'm using VSCODE and running the file with the extension page

STEP 2: Search for "executor map", then, "edit json" extension configuration

STEP 3: On the json file, look for "kotlin" and edit the "$filename" to the dot or asterisk (whatever work for you) edit defaut code runner

STEP 4: Save the file and you're good to go

  • Related