Scripts चलाना
एक Ruby script instructions की एक saved file है जिसे आप एक command से चलाते हैं। यह शुरू से अंत तक एक recipe play करने जैसा है।
In this page:
Syntax
ruby script_name.rb
Scripts चलाना
एक Ruby script command line से ruby filename.rb से चलती है, हर statement top to bottom execute करते हुए। यह एक complete Ruby program चलाने का standard तरीका है, IRB में interactively experiment करने के उलट।
.rb extension एक convention है, एक strict requirement नहीं।
Note:
ruby -c filename.rb बिना actually चलाए एक script की syntax check करता है।उदाहरण: Running Scripts
# Run a Ruby script from the command line
ruby hello.rb
# Check syntax without running it
ruby -c hello.rb
⚠️ Run this in your own terminal or Node.js environment.
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. #}
आम गलतियां
.rbके बिनाruby helloचलाना जब file का नामhello.rbहो, इसलिए Ruby इसे नहीं ढूंढ पाता।- एक अलग folder से command चलाना, इसलिए Ruby
No such file or directoryreport करता है। - यह भूल जाना कि
ruby -c hello.rbसिर्फ syntax check करता है और code चलाता नहीं है।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: