Scala IDE Youtube Training Question

scala

#1

In the youtube video which is shared by Durga i.e.,

At 8:28 timing, How can we run the Project as Scala application with out supplying parameter to main function ? Later in the scala interpreter, the parameter is supplied because Main function is expecting a string. Doesn’t that apply when RUN as SCALA Application?

Could you please clarify.


#2

@chandramouli_ravi

def main(args: Array[String])

Here in the IDE we are passing argument as String so main function is having a parameter as String. By running scala application we can see the output as “hello world”. In the interpreter we must pass a parameter as string because the main function expects a string to be the output. I hope I answered your question?


#3

Thanks Sunil.
Same code is present in both IDE and interpreter.

I got the interpreter part but did not get the IDE part.

Here in the IDE we are passing argument as String so main function is having a parameter as String.

Code is there to accept STRING Array. But when run in IDE as Scala Application, i don’t understand how and where Argument is being passed. Can you please elaborate? With out argument, i expect the application to fail but its printing Hello world. Is it because we are not trying to read args array in the program? I am guessing if we refer to args[0], i guess it will fail as out of bounds exception.