I am trying to create an enum datatype for relationships in my apex class. Below is the code I am using:

public Enum Enum_RelationShipCode {Father, Mother, Brother, Sister, Uncle, Aunt, Brother-In-Law, Daughter-In-Law, Child}

However, I am getting compile errors when trying to save the class as below.

Expecting '}' but was: '-'
Unexpected Token ','.
Unexpected Token '}'

Can someone help? It appears that Salesforce enums are not supporting hyphens in them.

2 Answers 2


If you want any sort of word separation, you would need to use underscores instead, which are allowed.

public Enum RelationshipCode { BROTHER_IN_LAW }

The - character, outside of a string, can only be used as a minus sign (negation or subtraction, depending on what's to the left of it), or as the decrement operator (--). It cannot be used as part of a "token", such as a field name, class name, variable name, enum, constant, function name, etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .