What is the difference between .sc and .scala file?
Asked Answered
P

1

18

I am learning scala and got know that we can save scala file using two extensions, that is my.sc and my.scala.

Here is the sample file which i created:

my.scala

object My {

  /** Our main function where the action happens */
  def main(args: Array[String]) {


    Logger.getLogger("org").setLevel(Level.ERROR)
    val sc = new SparkContext("local[*]", "my")
    val lines = sc.textFile("readme.tx")
    val results = lines.countByValue()

   }
}

my.sc

object My {

  val hello: String = "Hello World!"
  println(hello)
}

What is the difference between the two?

When to use sc file extension and when to use scala file extension?

Photodynamics answered 19/10, 2018 at 16:55 Comment(2)
I have checked that in some course at udemy.Photodynamics
Well, they have every right to name their files however they want. What does it have to do with Apache-Spark and/or Scala-IDE?Keratose
S
24

A .scala file is a regular Scala file, in order to be compiled and ran as a regular program. This is the most common scala file that you will use

An .sc file is a worksheet or a scratch, it is a file that will be evaluated as you save it, the result for each expression is shown in a column to the right of your IDE. Worksheets are like a REPL session. It is useful to test some code in a quick way, just as you can do with the REPL.

Edit

Awesome explanation here

What is the difference between scala classes, scripts and worksheets in Intellij-idea?

Sochi answered 19/10, 2018 at 17:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.