Comments क्या हैं
Comments लोगों के लिए notes होते हैं जिन्हें Scala नज़रअंदाज़ करता है, जैसे किसी recipe पर एक sticky note। वे program का व्यवहार बदले बिना आपकी सोच समझाते हैं।
In this page:
Syntax
// single-line comment
/* multi-line
comment */
Comments
Scala में // एक single-line comment शुरू करता है, और /* ... */ एक multi-line comment block को wrap करता है।
Scaladoc comments, जो /** ... */ के रूप में लिखे जाते हैं, API documentation generate करने के लिए उपयोग होते हैं और classes, objects, और methods के ऊपर दिखाई दे सकते हैं। Comments को वह न दोहराकर, जो code पहले से स्पष्ट करता है, गैर-स्पष्ट reasoning समझानी चाहिए।
Note:
/** ... */ (double-star) Scaladoc comments को documentation-generation tools पहचानते हैं, साधारण /* ... */ comments के विपरीत।उदाहरण: Comments
object Main extends App {
// This is a single-line comment
val x = 10 // inline comment after code
/* This is a
multi-line comment block */
/** Scaladoc comment describing this value. */
val y = 20
println(x + y)
}
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. #}
आम गलतियां
/* ... /* ... */ ... */को nest करना और उम्मीद करना कि इसे नज़रअंदाज़ किया जाएगा, जबकि Scala nested comments को support करता है लेकिन missing closing*/बाकी file को comment कर देता है।- comments के लिए अन्य languages की तरह
#या--का उपयोग करना, जबकि Scala//और/* */उपयोग करता है। - जिस definition को document करना है उससे दूर
/** ... */Scaladoc comment लिखना, जिससे यह किसी से जुड़ता नहीं।
चैप्टर सारांश
- Scala को installation, REPL, और scripts चलाने के साथ set up किया जाता है, और programs की एक निश्चित structure होती है।
objectऔरclassमूल building blocks हैं।println,print, और comments output पैदा करते हैं और code को document करते हैं।
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: