I have different object snippet at many places (shown below) and I want below 4 lines to be converted into a single line. How we can do it in Apex ?
Map<String, List<Configuration__c>> mapConfig = new Map<String, List<Configuration__c>>();
Configuration__c c = // detail coming from DB here
List<Configuration__c> tempList = serviceTypeFieldsMap.get(detail.ServiceType__c);
tempList.add(c);
mapConfig.put(detail.ServiceType__c, tempList);
I tried many things, but did not worked out.
mapConfig.put(detail.ServiceType__c, serviceTypeFieldsMap.get(detail.ServiceType__c).add(c));