Method :
public List<Case> getCaseDetails()
{
List<Case> cd = new List<Case>();
if(cd == null) cd = [SELECT Field1__c,Field2_Contact__c FROM Case WHERE Field1__c =:currentRecordId limit 1 ];
return cd;
}
While testing this method in Dev Console , it's returning empty List . Can you please help me in finding what is missing/wrong?
cd
list is never null as you have initialized it just above. so theif
condition get failed and returns the empty list. Anyway I'm not seeing any benefit of checking for null or empty just after initializing the list as you know it's not null and it's empty