Statements और Chunks
एक Lua file एक chunk है, statements की एक list जिसे semicolons या किसी special ending की ज़रूरत नहीं।
In this page:
Statements और Chunks
एक chunk statements की कोई भी sequence है और वह unit है जिसे Lua compile और run करता है, या तो एक file या एक string। Statements whitespace से separated होते हैं, और semicolons optional हैं। main chunk खुद एक function है जो command-line arguments को varargs की तरह receive करता है।
Note:
जब आपको अपने local variables वाला एक block चाहिए तो code को do ... end में wrap करें।
उदाहरण: Statements and chunks
local a = 1; local b = 2
print(a + b)
do
local hidden = "inside block"
print(hidden)
end
print(select("#", ...))
print(load("return 6 * 7")())
-- Output:
-- 3
-- inside block
-- 0
-- 42
Login to try C/C++/Java/PHP code in the editor
आम गलतियां
- habit से हर line के अंत में एक semicolon लगाना और सोचना कि यह required है
- एक line को parenthesis से शुरू करना और गलती से पिछला statement continue करना
- एक block के बाद end भूल जाना
चैप्टर सारांश
- एक chunk statements की एक sequence है
- Semicolons optional हैं
- main chunk arguments ... की तरह receive करता है
- do ... end एक explicit block बनाता है
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: