How to run a Scala script within IntelliJ IDEA?

前端 未结 4 1978
野的像风
野的像风 2021-02-05 02:05

Here is a trivial scala script:

object test {
  def hi() { print(\"hi there from here\") }
}


test.hi()

From the command line it does the expe

4条回答
  •  深忆病人
    2021-02-05 02:56

    There are 2 things to understand first. Scala works as both interpreter and compiler. You are trying to with interpreter "scala test.scala" without using "scalac test.scala" and interpreter works without main method also.

    Other way you can do in intellij is open the terminal or command prompt in intellij and run scala test.scala from the file location (Pre-requisite is scala in present the system path)

提交回复
热议问题