Thuta Learning
ရှာဖွေရန်
BasicProgrammingbeginner

Operators

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

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

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Condition ထဲမှာ if wallet = price လို့ရေးတာမှားပါတယ်။ နှိုင်းယှဉ်ချင်ရင် == , > , , >= စတာတွေသုံးရပါတယ်။
Operators | Thuta Learning