ရိုးရိုးလေး ရှင်းပြမယ်
Syntax & Hello World ကို ရိုးရိုးလေးနားလည်မယ်
Swift syntax က ရှင်းလင်းပြီး ဖတ်ရလွယ်ပါတယ်။ Java/C# လို main() function တစ်ခုအမြဲရေးစရာမလိုဘဲ Playground ထဲမှာ code ကို အပေါ်ကနေအောက်ကို run လုပ်နိုင်ပါတယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Quote မပိတ်တာ၊ parenthesis မပိတ်တာ၊ spelling မှားတာတွေက beginner တွေမှာအများဆုံးတွေ့ရတဲ့ syntax error တွေပါ။
ဖြစ်လေ့ရှိတဲ့အမှား
Sample output တစ်ခုမှန်ရုံဖြင့်nil, ownership, actor isolation နဲ့error paths အားလုံးမှန်ပြီဟုယူဆခြင်း။
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Syntax & Hello World ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
- Typed value
- Swift expression / function
- Safe result
Syntax & Hello World ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
import Foundation
// Program စတင် run သည့်အခါ ဒီလိုင်းက console ထဲကို text ထုတ်ပြမယ်။
print("Hello, World!")Syntax & Hello World ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Typed value
import FoundationSwift syntax က ရှင်းလင်းပြီး ဖတ်ရလွယ်ပါတယ်။ Java/C# လို main() function တစ်ခုအမြဲရေးစရာမလိုဘဲ Playground ထဲမှာ code ကို အပေါ်ကနေအောက်ကို run လုပ်နိုင်ပါတယ်။
- Swift expression / function
// Program စတင် run သည့်အခါ ဒီလိုင်းက console ထဲကို t...Syntax & Hello World ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
- Safe result
print("Hello, World!")Syntax & Hello World example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
- Typed value
- Swift expression / function
- Safe result
Success
Syntax & Hello World ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
Failure
Quote မပိတ်တာ၊ parenthesis မပိတ်တာ၊ spelling မှားတာတွေက beginner တွေမှာအများဆုံးတွေ့ရတဲ့ syntax error တွေပါ။
Swift syntax က ရှင်းလင်းပြီး ဖတ်ရလွယ်ပါတယ်။ Java/C# လို main() function တစ်ခုအမြဲရေးစရာမလိုဘဲ Playground ထဲမှာ code ကို အပေါ်ကနေအောက်ကို run လုပ်နိုင်ပါတယ်။
import Foundation က dates, strings, collections စတဲ့ common utility တွေသုံးဖို့ Foundation framework ကိုခေါ်တာပါ။ Simple print example အတွက် မဖြစ်မနေမလိုပေမယ့် real code တွေမှာ အသုံးများပါတယ်။
import Foundation
// Program စတင် run သည့်အခါ ဒီလိုင်းက console ထဲကို text ထုတ်ပြမယ်။
print("Hello, World!")Swift က code ကို top-to-bottom ဖတ်ပါတယ်။ ဒီ example မှာ Foundation ကို import လုပ်ပြီး print() function နဲ့ text တစ်ကြောင်းထုတ်ပြထားပါတယ်။
Hello, World!Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Syntax & Hello World example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Syntax & Hello World example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
import Foundation
// Program စတင် run သည့်အခါ ဒီလိုင်းက console ထဲကို text ထုတ်ပြမယ်။
print("Hello, World!")ရလဒ်: Syntax & Hello World ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Syntax & Hello World example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Typed value → Swift expression / function → Safe result
- Syntax & Hello World ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
- Quote မပိတ်တာ၊ parenthesis မပိတ်တာ၊ spelling မှားတာတွေက beginner တွေမှာအများဆုံးတွေ့ရတဲ့ syntax error တွေပါ။
- Syntax & Hello World example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
Swift 6.2 Released — Swift.org