ရိုးရိုးလေး ရှင်းပြမယ်
Operators ကို ရိုးရိုးလေးနားလည်မယ်
Operators တွေက တန်ဖိုးတွေကိုတွက်ချက်၊ နှိုင်းယှဉ်၊ logic စစ်ဆေးဖို့သုံးတဲ့ symbols တွေပါ။ Swift မှာ arithmetic, assignment, comparison, logical operator တွေကိုနေ့တိုင်းနီးပါးသုံးရပါမယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Condition ထဲမှာ if wallet = price လို့ရေးတာမှားပါတယ်။ နှိုင်းယှဉ်ချင်ရင် == , > , , >= စတာတွေသုံးရပါတယ်။
ဖြစ်လေ့ရှိတဲ့အမှား
Sample output တစ်ခုမှန်ရုံဖြင့်nil, ownership, actor isolation နဲ့error paths အားလုံးမှန်ပြီဟုယူဆခြင်း။
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Operators ကို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
Operators ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
let price = 1200
let quantity = 3
let total = price * quantity
var wallet = 5000
wallet -= total
let canBuyAgain = wallet >= price
print("Total: \(total)")
print("Wallet left: \(wallet)")
print("Can buy again: \(canBuyAgain)")Operators ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Typed value
let price = 1200Operators တွေက တန်ဖိုးတွေကိုတွက်ချက်၊ နှိုင်းယှဉ်၊ logic စစ်ဆေးဖို့သုံးတဲ့ symbols တွေပါ။ Swift မှာ arithmetic, assignment, comparison, logical operator တွေကိုနေ့တိုင်းနီးပါးသုံးရပါမယ်။
- Swift expression / function
wallet -= totalOperators ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
- Safe result
print("Can buy again: \(canBuyAgain)")Operators 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
Operators ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
Failure
Condition ထဲမှာ if wallet = price လို့ရေးတာမှားပါတယ်။ နှိုင်းယှဉ်ချင်ရင် == , > , , >= စတာတွေသုံးရပါတယ်။
Operators တွေက တန်ဖိုးတွေကိုတွက်ချက်၊ နှိုင်းယှဉ်၊ logic စစ်ဆေးဖို့သုံးတဲ့ symbols တွေပါ။ Swift မှာ arithmetic, assignment, comparison, logical operator တွေကိုနေ့တိုင်းနီးပါးသုံးရပါမယ်။
let price = 1200
let quantity = 3
let total = price * quantity
var wallet = 5000
wallet -= total
let canBuyAgain = wallet >= price
print("Total: \(total)")
print("Wallet left: \(wallet)")
print("Can buy again: \(canBuyAgain)")* က multiplication, -= က လက်ရှိတန်ဖိုးထဲကနေလျှော့ခြင်း၊ >= က greater than or equal စစ်ခြင်းပါ။ Shopping cart, score system, usage credit calculation တွေမှာ ဒီ logic မျိုးကိုအသုံးများပါတယ်။
Total: 3600 Wallet left: 1400 Can buy again: trueReal-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Operators example ကိုempty, nil, boundary, invalid, error နဲ့cancellation cases ဖြင့်run/test လုပ်ပါ။ Value copy, shared reference, actor isolation နဲ့main-actor effects ကိုလိုအပ်သလိုစစ်ပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Operators 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 ကိုခန့်မှန်းပါ
let price = 1200
let quantity = 3
let total = price * quantity
var wallet = 5000
wallet -= total
let canBuyAgain = wallet >= price
print("Total: \(total)")
print("Wallet left: \(wallet)")
print("Can buy again: \(canBuyAgain)")ရလဒ်: Operators ရဲ့type, ownership နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Operators 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
- Operators ကိုSwift 6.2 type safety, definite initialization, Unicode, protocol-oriented design နဲ့strict concurrency ဆက်နွယ်မှုနဲ့နားလည်ပါ။ Compiler diagnostics ကိုdesign feedback အဖြစ်ယူပြီးclear intent နဲ့tests ကိုဦးစားပေးပါ။
- Condition ထဲမှာ if wallet = price လို့ရေးတာမှားပါတယ်။ နှိုင်းယှဉ်ချင်ရင် == , > , , >= စတာတွေသုံးရပါတယ်။
- Operators 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