更新:在 18" summer release 後,有類似的語法可以使用。
所以這篇基本上也不太需要存在了QQ
關於 「Switch-while Statements」的連結:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_switch.htm
先說我最近K資料得到的重點:while-case 在視覺上比起大量的 if-else 更容易理解,但是 Apex 因其可能存在的 「未定義行為」故不採用。
Staring with my resent note for certification-preparing: while-case is more visual pleasing then parallel-ed, if-else. But the possible "undefined, unwanted behavior" is probably the reason why Apex doesn't have it.
定義:while-case 語法是類C語言中,用來處理大量、等階(相同時間點) if-else 語法時,運用「案例」的觀念,進而折疊、縮短程式碼並增加可讀性的功能。
Define: While-case is a method with the understanding of "case", for C-Like language to shorten and increase readability in code.
而 Apex 語法最主要的存在的目的是提供 SFDC 上的服務,所以在雲端開發、多租戶的前提下,程式碼的行為、記憶體的邊界,比什麼都重要。
Apex, on the other hand, as the main Language on SFDC, with the purpose of cloud development/compiling/execution and with multitenant awareness, guards closely against runaway code by enforcing limits, which prevent code from monopolizing shared resources.
關於 「Switch-while Statements」的連結:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_switch.htm
先說我最近K資料得到的重點:while-case 在視覺上比起大量的 if-else 更容易理解,但是 Apex 因其可能存在的 「未定義行為」故不採用。
Staring with my resent note for certification-preparing: while-case is more visual pleasing then parallel-ed, if-else. But the possible "undefined, unwanted behavior" is probably the reason why Apex doesn't have it.
定義:while-case 語法是類C語言中,用來處理大量、等階(相同時間點) if-else 語法時,運用「案例」的觀念,進而折疊、縮短程式碼並增加可讀性的功能。
Define: While-case is a method with the understanding of "case", for C-Like language to shorten and increase readability in code.
而 Apex 語法最主要的存在的目的是提供 SFDC 上的服務,所以在雲端開發、多租戶的前提下,程式碼的行為、記憶體的邊界,比什麼都重要。
Apex, on the other hand, as the main Language on SFDC, with the purpose of cloud development/compiling/execution and with multitenant awareness, guards closely against runaway code by enforcing limits, which prevent code from monopolizing shared resources.