Q:

Can I compile a Scala file with a different name than the class?

Can I compile a Scala file with a different name than the class?
   object HelloWorld {
      def main(args: Array[String]): Unit = {
        println("Hello, world!")
      }
    }

Hello.scala

A:

Have you tried? Then you would notice that, yes, you can. Indeed you can place multiple classes in the same file, and therefore there is no restriction as to how the file must be called.

