Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run object scala in databricks

I am trying to execute sample code on databricks in scala. It is an object.

object Main {
  def main(args: Array[String]) {
    val res = for (a <- args) yield a.toUpperCase
    println("Arguments: " + res.toString)
  }
}

When I run on databricks; it says 'object defined main'. I am not sure how to execute it now or what is the code to execute it. Please help.

like image 918
Shraddha Avatar asked Sep 11 '25 14:09

Shraddha


1 Answers

What you are working with is kind of scala REPL. Basically "main" function does not have any significance over there. Having said that you can run your function as follows

object Main {
  def main(args: Array[String]) {
    val res = for (a <- args) yield a.toUpperCase
    println(res)
    println("Arguments: " + res.toString)
  }
}

Main.main(Array("123","23123"))

As is you can call Object Main's main method.

like image 151
Biswanath Avatar answered Sep 13 '25 06:09

Biswanath