← Back to Lua Course | Chapter 1: Introduction | Lesson 4 of 7

Comments का उपयोग

Comments मनुष्यों के लिए notes हैं जिन्हें Lua program चलते वक्त ignore करता है।

In this page:

  1. Comments

Comments

एक single-line comment दो dashes से शुरू होता है और line के अंत तक रहता है। एक block comment --[[ से शुरू होता है और ]] से खत्म होता है। Comments code explain करने या इसे temporarily disable करने के लिए इस्तेमाल हो सकते हैं।

Note: Opening में एक और dash add करना, जैसे ---[[, एक single character से block comment बंद कर देता है।

उदाहरण: Comments

lua
-- this is a single-line comment
print("visible") -- comment after code

--[[
print("this line is commented out")
print("and so is this one")
]]

--[==[ a block that may contain ]] safely ]==]
print("done")

-- Output:
-- visible
-- done
{# 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. दूसरी languages की तरह comments के लिए // या # इस्तेमाल करना
  2. एक block comment का closing ]] भूल जाना
  3. level markers जैसे --[=[ इस्तेमाल किए बिना block comments nest करना
चैप्टर सारांश
  • -- एक line comment शुरू करता है
  • --[[ ]] एक block comment बनाता है
  • Comments को Lua ignore करता है
  • --[==[ जैसे level markers comments के अंदर ]] allow करते हैं
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 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.