ရိုးရိုးလေး ရှင်းပြမယ်
Exercise Set 1: Basic Syntax Practice ကို ရိုးရိုးလေးနားလည်မယ်
ဒီ lesson က teaching content အသစ် မဟုတ်ဘဲ Basic chapter မှာ သင်ခဲ့တဲ့ syntax fundamentals တွေကို လက်တွေ့ practice လုပ်ဖို့ ရည်ရွယ်ထားတဲ့ exercise set ဖြစ်ပါတယ်။ Task တစ်ခုချင်းစီဟာ concept တစ်ခုတည်းအပေါ် focus ထားပြီး copy-paste မလုပ်ဘဲ ကိုယ်တိုင်ရေးမှ အကျိုးရှိမှာပါ။ Difficulty level က warm-up အနေနဲ့ ရိုးရှင်းအောင် ထားထားပြီး Exercise Set 2 မှာ Intermediate/Advanced level ကို တက်သွားပါလိမ့်မယ်။ အောက်က task တွေကို ဖြေပြီးရင် code ကို run ပြီး output ကို prediction လုပ်ထားတာနဲ့ တိုက်စစ်ကြည့်ပါ။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
switch statement မှာ range pattern (60...79 လို) သုံးရမှာကို if-else chain ရှည်ရှည်နဲ့ ရေးနေတတ်ကြတယ်
ဖြစ်လေ့ရှိတဲ့အမှား
dictionary loop လုပ်တဲ့အခါ (key, value) tuple ဖြစ်တာကို မသိဘဲ .values ပဲ ခေါ်ပြီး key ကို လွဲချော်တတ်ကြတယ်
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Exercise Set 1: Basic Syntax Practice ကိုUI, domain state, persistence/service နဲ့tests ခွဲထားသောvertical slices ဖြင့်လုပ်ပါ။ Normal, boundary, nil, error, cancellation နဲ့concurrency paths ကိုrepeatable tests ဖြင့်စစ်ပြီးmain-actor work ကိုမပိတ်ပါနှင့်။
- လိုအပ်ချက်
- စဉ်းစားပြီး implement
- စမ်းသပ်ပြီးရှင်းပြ
Exercise Set 1: Basic Syntax Practice ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
// Task 1
func isEven(number: Int) -> Bool {
// TODO: implement
return false
}
// Task 2
let fruits = ["Apple", "Banana", "Mango"]
// TODO: for-in loop with index
// Task 3
let scores: [String: Int] = ["Aung": 80, "Su": 65, "Ko Ko": 90]
// TODO: calculate average
// Task 4
func gradeCategory(score: Int) -> String {
// TODO: switch statement with ranges
return ""
}
print(isEven(number: 4))
print(gradeCategory(score: 75))Exercise Set 1: Basic Syntax Practice ကိုUI, domain state, persistence/service နဲ့tests ခွဲထားသောvertical slices ဖြင့်လုပ်ပါ။ Normal, boundary, nil, error, cancellation နဲ့concurrency paths ကိုrepeatable tests ဖြင့်စစ်ပြီးmain-actor work ကိုမပိတ်ပါနှင့်။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- လိုအပ်ချက်
// Task 1ဒီ lesson က teaching content အသစ် မဟုတ်ဘဲ Basic chapter မှာ သင်ခဲ့တဲ့ syntax fundamentals တွေကို လက်တွေ့ practice လုပ်ဖို့ ရည်ရွယ်ထားတဲ့ exercise set ဖြစ်ပါတယ်။ Task တစ်ခုချင်းစီဟာ concept တစ်ခုတည်းအပေါ် focus ထားပြီး copy-paste မလုပ်ဘဲ ကိုယ်တိုင်ရေးမှ အကျိုးရှိမှာပါ။ Difficulty level က warm-up အနေနဲ့ ရိုးရှင်းအောင် ထားထားပြီး Exercise Set 2 မှာ Intermediate/Advanced level ကို တက်သွားပါလိမ့်မယ်။ အောက်က task တွေကို ဖြေပြီးရင် code ကို run ပြီး output ကို prediction လုပ်ထားတာနဲ့ တိုက်စစ်ကြည့်ပါ။
- စဉ်းစားပြီး implement
let scores: [String: Int] = ["Aung": 80, "Su": 65, "K...Exercise Set 1: Basic Syntax Practice ကိုUI, domain state, persistence/service နဲ့tests ခွဲထားသောvertical slices ဖြင့်လုပ်ပါ။ Normal, boundary, nil, error, cancellation နဲ့concurrency paths ကိုrepeatable tests ဖြင့်စစ်ပြီးmain-actor work ကိုမပိတ်ပါနှင့်။
- စမ်းသပ်ပြီးရှင်းပြ
print(gradeCategory(score: 75))Exercise Set 1: Basic Syntax Practice example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
- လိုအပ်ချက်
- စဉ်းစားပြီး implement
- စမ်းသပ်ပြီးရှင်းပြ
Success
Exercise Set 1: Basic Syntax Practice ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
Failure
switch statement မှာ range pattern (60...79 လို) သုံးရမှာကို if-else chain ရှည်ရှည်နဲ့ ရေးနေတတ်ကြတယ်
ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
ဒီ lesson က teaching content အသစ် မဟုတ်ဘဲ Basic chapter မှာ သင်ခဲ့တဲ့ syntax fundamentals တွေကို လက်တွေ့ practice လုပ်ဖို့ ရည်ရွယ်ထားတဲ့ exercise set ဖြစ်ပါတယ်။ Task တစ်ခုချင်းစီဟာ concept တစ်ခုတည်းအပေါ် focus ထားပြီး copy-paste မလုပ်ဘဲ ကိုယ်တိုင်ရေးမှ အကျိုးရှိမှာပါ။ Difficulty level က warm-up အနေနဲ့ ရိုးရှင်းအောင် ထားထားပြီး Exercise Set 2 မှာ Intermediate/Advanced level ကို တက်သွားပါလိမ့်မယ်။ အောက်က task တွေကို ဖြေပြီးရင် code ကို run ပြီး output ကို prediction လုပ်ထားတာနဲ့ တိုက်စစ်ကြည့်ပါ။
လေ့ကျင့်ခန်းများ
Task 1: function isEven(number: Int) -> Bool ကို ရေးပြီး even ဆိုရင် true ပြန်ပါ။ Task 2: fruits ဆိုတဲ့ [String] array တစ်ခု ဆောက်ပြီး for-in loop နဲ့ index နဲ့ item ကို "1. Apple" ပုံစံ print ထုတ်ပါ။ Task 3: scores ဆိုတဲ့ [String: Int] dictionary (student name to score) ဆောက်ပြီး loop နဲ့ average ကို calculate လုပ်ပါ။ Task 4: switch statement သုံးပြီး integer input တစ်ခုကို 0-59 fail, 60-79 pass, 80-100 excellent ဆိုပြီး category classify လုပ်တဲ့ function ရေးပါ။
Code နမူနာ
// Task 1
func isEven(number: Int) -> Bool {
// TODO: implement
return false
}
// Task 2
let fruits = ["Apple", "Banana", "Mango"]
// TODO: for-in loop with index
// Task 3
let scores: [String: Int] = ["Aung": 80, "Su": 65, "Ko Ko": 90]
// TODO: calculate average
// Task 4
func gradeCategory(score: Int) -> String {
// TODO: switch statement with ranges
return ""
}
print(isEven(number: 4))
print(gradeCategory(score: 75))isEven(number: 4) က true ပြန်ပေးပြီး၊ fruits list က number ပါတဲ့ line သုံးကြောင်း print ထွက်ကာ၊ gradeCategory(score: 75) က "Pass" ပြန်ပေးသင့်ပါတယ်။၅ မိနစ် စမ်းကြည့်
Task 4 ကို ပြီးရင် score အနုတ်ကိန်း (-5) ကို input ပေးကြည့်ပြီး invalid case အတွက် "Invalid" ပြန်ပေးအောင် default case ထပ်ထည့်ကြည့်ပါ- 5 minute အတွင်း ဖြေကြည့်ပါ။
သတိလေးတစ်ချက်
Task တစ်ခုစီကို solution မကြည့်ခင် ကိုယ့်ဘာသာ 5 မိနစ်လောက် အရင်ကြိုးစားကြည့်ပါ - error message ကိုယ်တိုင်ဖတ်ပြီး debug လုပ်တဲ့ practice ကသာ Basic concept တွေကို firm ဖြစ်စေပါလိမ့်မယ်။
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Exercise Set 1: Basic Syntax Practice example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Exercise Set 1: Basic Syntax Practice 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 ကိုခန့်မှန်းပါ
// Task 1
func isEven(number: Int) -> Bool {
// TODO: implement
return false
}
// Task 2
let fruits = ["Apple", "Banana", "Mango"]
// TODO: for-in loop with index
// Task 3
let scores: [String: Int] = ["Aung": 80, "Su": 65, "Ko Ko": 90]
// TODO: calculate average
// Task 4
func gradeCategory(score: Int) -> String {
// TODO: switch statement with ranges
return ""
}
print(isEven(number: 4))
print(gradeCategory(score: 75))ရလဒ်: Exercise Set 1: Basic Syntax Practice ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Exercise Set 1: Basic Syntax Practice 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
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- လိုအပ်ချက် → စဉ်းစားပြီး implement → စမ်းသပ်ပြီးရှင်းပြ
- Exercise Set 1: Basic Syntax Practice ကိုUI, domain state, persistence/service နဲ့tests ခွဲထားသောvertical slices ဖြင့်လုပ်ပါ။ Normal, boundary, nil, error, cancellation နဲ့concurrency paths ကိုrepeatable tests ဖြင့်စစ်ပြီးmain-actor work ကိုမပိတ်ပါနှင့်။
- switch statement မှာ range pattern (60...79 လို) သုံးရမှာကို if-else chain ရှည်ရှည်နဲ့ ရေးနေတတ်ကြတယ်
- Exercise Set 1: Basic Syntax Practice example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
The Swift Programming Language — Swift.org