A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2306 below:

[apex] Switch statements are not parsed/supported · Issue #2306 · pmd/pmd · GitHub

Switch statements. It seems like these don't parse in the current version of PMD?

@adangel I just reread this and saw that Apex switch statement still not seem to be supported. I am sure we added such a contribution long ago. Can you recall if that's true and already released?

Originally posted by @rsoesemann in #2297 (comment)

Example (from https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_switch.htm):

public class ApexSwitchStatements {
    public void example1() {
        int i = 3;
        switch on i {
           when 2 {
               System.debug('when block 2');
           }
           when 3, 4, 5 {
               System.debug('when block 3 and 4 and 5');
           }
           when 6, 7 {
               System.debug('when block 6 and 7');
           }
           when -3 {
               System.debug('when block -3');
           }
           when null {
               System.debug('bad integer');
           }
           when else {
               System.debug('default');
           }
        }
    }

    public void example2() {
        int i = 1;
        switch on someInteger(i) {
           when 2 {
               System.debug('when block 2');
           }
           when 3 {
               System.debug('when block 3');
           }
           when else {
               System.debug('default');
           }
        }
    }
    private int someInteger(int i) {
        return i + 1;
    }

    public void example3() {
        switch on sobject {
           when Account a {
               System.debug('account ' + a);
           }
           when Contact c {
               System.debug('contact ' + c);
           }
           when null {
               System.debug('null');
           }
           when else {
               System.debug('default');
           }
        }
    }

    public void example4() {
        switch on season {
           when WINTER {
               System.debug('boots');
           }
           when SPRING, SUMMER {
               System.debug('sandals');
           }
           when else {
               System.debug('none of the above');
           }
        }
    }
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4