Here is a trivial scala script:
object test {
def hi() { print(\"hi there from here\") }
}
test.hi()
From the command line it does the expe
Your code works in command line because it is "script", when you want to make it runnable in project there are ways to do it:
By creating object which extends App
object test {
def hi() { print("hi there from here") }
}
object runnable extends App {
test.hi()
}
or java-like solution i.e. creating main method
object test {
def hi() { print("hi there from here") }
}
object runnable {
def main(args: Array[String]) {
test.hi()
}
}
when need to execute as script - I do it like that: select code to execute by mouse, then choose from context menu "Send Selection To Scala Console"