What is the difference between using and not using get; set;
in data passed from backend?
I saw examples like this in Apex:
using get; set;
public with sharing class MyBackendController {
public class WrapperDataClass {
@AuraEnabled
List<Contact> contactsList {get; set;}
}
@AuraEnabled
public static WrapperDataClass doesnotMatter() {
WrapperDataClass res = new WrapperDataClass();
//does not matter how res is filled
return res;
}
}
not using get; set;
public with sharing class MyBackendController {
public class WrapperDataClass {
@AuraEnabled
List<Contact> contactsList;
}
@AuraEnabled
public static WrapperDataClass doesnotMatter() {
WrapperDataClass res = new WrapperDataClass();
//does not matter how res is filled
return res;
}
}
Previously I thought that using get; set;
is obligatory. But I forgot to include it a few times in my code and still everything worked the same way.
So, I am going not to use get; set;
at all. Will I be fine or am I missing something?
Thank you.