← Back to Scala Course | Chapter 1: Setup & Basics | Lesson 4 of 8

scala से Scripts चलाना

आप बिना किसी अतिरिक्त step के terminal से सीधे एक Scala file चला सकते हैं। यह speaker बनाने के बजाय किसी saved song पर play दबाने जैसा है।
Syntax
scala
scala FileName.scala

Running Scripts with scala

scala command बिना अलग compile step के सीधे .scala file चला सकता है, जिससे यह quick scripts के लिए सुविधाजनक है, हालांकि यह चलाने से पहले आंतरिक रूप से compile करता है।

बड़े projects के लिए, scalac पहले से .class files में compile करता है, जो बार-बार चलाने पर तेज़ चलती हैं। Judge0 आपके submitted code को चलाने से पहले scalac से compile करता है।

Note: scala file.scala एक ही command में script को compile और run करता है, जो quick, one-off programs के लिए आदर्श है।

उदाहरण: Running Scripts with scala

markup
object Main extends App {
  println("This program was compiled and run via the scala toolchain")
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. बिना .scala extension वाले file name पर scala Hello चलाना, जिससे file नहीं मिलती।
  2. बिना किसी object के main method define करना, जिससे script के पास चलाने के लिए कोई entry point नहीं होता।
  3. यह उम्मीद करना कि बार-बार चलाने पर script तेज़ होगी, जबकि यह हर बार फिर से compile होती है; compiled build के लिए scalac का उपयोग करें।
🔒

Chapter Quiz — Complete all 8 topics to unlock

0/8 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.