Scala giving me “illegal start of definition”

后端 未结 5 496
死守一世寂寞
死守一世寂寞 2020-12-13 16:48

I\'m trying to get started with Scala and cannot get out of the starting gate.

A file consisting of the line

package x

gives me

5条回答
  •  误落风尘
    2020-12-13 17:29

    Since Scala 2.11.0-M7 you can use :paste -raw (fix for issue SI-5299). This option allows defining packages in the REPL:

    scala> :paste -raw
    // Entering paste mode (ctrl-D to finish)
    
    package Foo
    
    class Bar
    
    // Exiting paste mode, now interpreting.
    
    
    scala> import Foo._
    import Foo._
    
    scala> new Bar
    res1: Foo.Bar = Foo.Bar@3ee2cf81
    

提交回复
热议问题