Why I can't execute scala file?

前端 未结 9 2081
日久生厌
日久生厌 2020-12-10 02:49

I am a newbie to Scala, it\'s the first time I\'m running Scala, when I installed Scala, I created a file named Hello.scala, the content is:

pr         


        
9条回答
  •  我在风中等你
    2020-12-10 03:33

    To execute external script (load all definitions from it) in REPL use :load command instead of scala .

    » echo 'println("HelloWorld")' > Hello.scala
    » scala
    Welcome to Scala version 2.9.2 (OpenJDK Client VM, Java 1.6.0_24).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    // is this what you tried to do?
    scala> scala Hello.scala
    :1: error: ';' expected but '.' found.
       scala Hello.scala
    
    // do this instead
    scala> :load Hello.scala
    Loading Hello.scala...
    HelloWorld
    
    scala>
    

提交回复
热议问题