Operators တွေက တန်ဖိုးတွေကိုတွက်ချက်၊ နှိုင်းယှဉ်၊ logic စစ်ဆေးဖို့သုံးတဲ့ symbols တွေပါ။ Swift မှာ arithmetic, assignment, comparison, logical operator တွေကိုနေ့တိုင်းနီးပါးသုံးရပါမယ်။
swift
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 မျိုးကိုအသုံးများပါတယ်။
You should see
Total: 3600 Wallet left: 1400 Can buy again: true