Questions tagged [ternary-operator]
The ternary-operator tag has no usage guidance.
4
questions
0
votes
1
answer
202
views
Apex ternary operator - Error: Compile Error: Expression cannot be a statement
Trying to simplify multifle if-else conditions . Below code is throwing error " Error: Compile Error: Expression cannot be a statement. " . Can you please let me know how to resolve the ...
0
votes
2
answers
423
views
How to rewrite that ternary operator code to if-else?
I can't understand that part of the code - how to rewrite this to if-s and else?
Especially the partthis.map1?.containsKey(custom_object__c?.workflow_status__c)
List<custom_object_2__c> ...
1
vote
1
answer
8k
views
A special ternary condition in apex (safe navigation operator)
I've seen this somewhere, sometime before but I can't remember how it's used and I can't find anything about it online (Probably because I don't know what to search for). So please help me understand ...
9
votes
2
answers
3k
views
Ternary Operator Compile Failure. Incompatible types in ternary operator
Assume we have some code in Apex:
APEX
Boolean isString = true; // or false
List<String> labels = new List<String>{ 'Label' };
Object entity = isString
? labels.get(0)
: ...