0
object ScalaTest{
    def main (args: Array[String]){
        var i =0

        while(i<=10){
            println(i)
            i +=1
        }
    }
}

When i do

c:\ Scalac ScalaTest.scala \\ it goes to the next line but
c:\ Scala ScalaTest.scala \\ Nothing is happening cursor is blinking in the next line but no response. 

What am i doing wrong here. Not able to see the output or anything. Please help.

Michael Zajac
  • 55,144
  • 7
  • 113
  • 138
StandForTheRight
  • 135
  • 3
  • 14

1 Answers1

1

The file you should execute with the scala command after compiling is not the source file but the resulting binary file from scalac.

If you take a look at: http://www.scala-lang.org/old/node/166

You should then try:

  scalac ScalaTest.scala

  scala ScalaTest

I tried your code in the REPL console and it's working ok. However, it might not be the most idiomatic Scala code ever.

It's a good approach to take a look at Range and trying something like:

  (0 to 10).foreach(println)

Which produce the same result without a mutable variable

Aurélien Thieriot
  • 5,853
  • 2
  • 24
  • 25
  • Hi Aurelien, Thank you very Much Actually "scala ScalaTest" Worked. But for the "Scala ScalaTest.scala" the console waited for about 45 mins then it gave be the below Error: "There is insufficient memory for the Java Runtime Environment to continue.Native memory allocation(malloc) failed to allocate 1048576 bytes for AllocateHeap.. Could not connect to compilation daemon after 300 attempts" .- I think .. may be due to no Ram Memory allocation. – StandForTheRight Sep 19 '15 at 15:51