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
akallioWileyakallioWiley 

Use an operator inside a Ternary Opeartor?

I am trying to increment a field based on if/else logic. I'm just starting to get the hang of the ternary operator. So, I wrote the following, but it won't compile. Does anybody know if it's possible to do this, or does it have to go in an if else statement?

 

conCD.CourseRoleCount__c = source == 'Course' ? +=1 : 0; 
akallioWileyakallioWiley

I just figured it out:

 

conCD.CourseRoleCount__c += source == 'Course' ? 1 : 0;