You need to sign in to do that
Don't have an account?

about ? wildcard
Hi Friends,
contact.LastName = nameParts.size() > 1 ? nameParts[nameParts.size()-1] : nameParts[0];
in the above statement, the "?" what it will check and what it means "nameParts[nameParts.size()-1] : nameParts[0]"
it isconfusing littlebit. please any one explain abt the line.
thanks,
Krish
contact.LastName = nameParts.size() > 1 ? nameParts[nameParts.size()-1] : nameParts[0];
in the above statement, the "?" what it will check and what it means "nameParts[nameParts.size()-1] : nameParts[0]"
it isconfusing littlebit. please any one explain abt the line.
thanks,
Krish
The line you posted contains a ternary operator. It is basically a shorter way for a one-line if-else statement.
It means:
Also check out the documentation (item 11) (https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_expressions_operators_understanding.htm).
Best regards,
Chris
visuallifecycle.net