function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chandrasekhar reddychandrasekhar reddy 

Error in creating Enum?

I have below Enum class.
 
public enum SfOperationStatus {
    SUCCESS("The SalesForce.com operation was successful."),
    Unsuccessful("The SalesForce.com operation was unsuccessful."),
    Error("An error occurred while executing the SalesForce.com operation."),
    ;
     private String msg;

    private SfOperationStatus(String message) {
        this.msg = message;
    }

    public String getMessage() {
        return this.msg;
    }
}
Above code gives below error.

Error: Compile Error: expecting right curly bracket, found '(' at line 2 column 11

Any help Please?
 
ShashankShashank (Salesforce Developers) 
Please check the syntax of the enum declaration: https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_enums.htm
SonamSonam (Salesforce Developers) 
I suppose you will have to define it as given in the code sample below:

Like :
public enum SfOperationStatus { SUCCESS, Unsuccessful, Error}

sample:

public enum Season {WINTER, SPRING, SUMMER, FALL} Season s = Season.SUMMER; if (s == Season.SUMMER) { // Will write the string value SUMMER System.debug(s); } else { System.debug('Not summer.'); }

reference:
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex3_6.htm