scala से Scripts चलाना
आप बिना किसी अतिरिक्त step के terminal से सीधे एक Scala file चला सकते हैं। यह speaker बनाने के बजाय किसी saved song पर play दबाने जैसा है।
In this page:
Syntax
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
object Main extends App {
println("This program was compiled and run via the scala toolchain")
}
Login to try C/C++/Java/PHP code in the editor
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. #}
आम गलतियां
- बिना
.scalaextension वाले file name परscala Helloचलाना, जिससे file नहीं मिलती। - बिना किसी
objectकेmainmethod define करना, जिससे script के पास चलाने के लिए कोई entry point नहीं होता। - यह उम्मीद करना कि बार-बार चलाने पर script तेज़ होगी, जबकि यह हर बार फिर से compile होती है; compiled build के लिए
scalacका उपयोग करें।
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: