gpt4 book ai didi

salesforce - Salesforce 中的 APEX 是否支持 SWITCH 和 CASE 语句?

转载 作者:行者123 更新时间:2023-12-04 00:07:40 25 4
gpt4 key购买 nike

用IF/THEN/ELSEIF/ELSE代替这个基本结构

int month = 8;
String monthString;
if (month == 1) {
monthString = "January";
} else if (month == 2) {
monthString = "February";
}
... // and so on

很高兴有
    int month = 8;
String monthString;
switch (month) {
case 1: monthString = "January";
break;
case 2: monthString = "February";
break;

..... // and so on

case 12: monthString = "December";
break;
default: monthString = "Invalid month";
break;
}

由于意图清晰,这将提高可读性并使调试更容易。

最佳答案

2018 - 是啊!!!! - 如果终于是 - 好消息 - Switch Now supported
跳到视频中的确切时间 YouTube of Session at golden moment

2014 年 - 遗憾的是此时没有。自 2009 年以来,我一直在等待此功能,下面社区的链接对它的要求很高。

Add "Switch" or "Case" Statement to Apex

关于salesforce - Salesforce 中的 APEX 是否支持 SWITCH 和 CASE 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22123415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com