Found some crazy apex syntax and I have no clue what it does.
public Account<List<String<Contact>>> whatIsWrongWithApex;
Is this a defect? Should this do something? Compiler not strict enough?
For the sake of the question, here is a simpler example:
public String<String> iThoughtThisShouldOnlyWorkForCollections;
Edit: Here is a full example where I instantiate an Account using this method and successfully insert it into the database:
public class ABug {
public Account<List<String<Contact>>> whatIsWrongWithApex;
public ABug() {
whatIsWrongWithApex = new Account<List<String<Contact>>>();
whatIsWrongWithApex.Name = 'Account Name';
insert whatIsWrongWithApex;
}
}
Anonymous Apex:
new ABug();
Attribution to: Phil Rymek
Possible Suggestion/Solution #1
This 'strange' syntax is a result of native Java support for Generics.
We cannot leverage the power of generics in Apex just yet, but the platform itself most certainly does. This is likely being exposed here through the definition & inheritance of the sObject class.
Attribution to: Mark Pond
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5133