99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Apex - if else語句

2019-10-26 16:26 更新

if-else語句

if語句后面可以有一個可選的else語句,當布爾表達式為false時執(zhí)行。


語法:

if boolean_expression {
   /* statement(s) will execute if the boolean expression is true */
} else {
   /* statement(s) will execute if the boolean expression is false */
}
如果布爾表達式的計算結(jié)果為true,則將執(zhí)行if代碼塊,否則將執(zhí)行代碼塊。


流程圖:


流程圖


示例:
假設(shè),我們的化工公司有兩類客戶:高級和正常。 根據(jù)客戶類型,我們應(yīng)該提供折扣和其他好處,如售后服務(wù)和支持。 下面是這個的實現(xiàn)。
//Execute this code in Developer Console and see the Output
String customerName = 'Glenmarkone'; //premium customer
Decimal discountRate = 0;
Boolean premiumSupport = false;
if (customerName == 'Glenmarkone') {
    discountRate = 0.1; //when condition is met this block will be executed
    premiumSupport = true;
    System.debug('Special Discount given as Customer is Premium');
}
else {
    discountRate = 0.05; //when condition is not met and customer is normal
    premiumSupport = false;
    System.debug('Special Discount Not given as Customer is not Premium');
}
由于“Glenmarkone”是一個高級客戶,所以if塊將基于條件執(zhí)行,在其余情況下,else條件將被觸發(fā)。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號