salesforce - How to increment a value in a map with Apex? -
is there way increment value in map without needing second variable?
for example, doesn't work:
counts = new map<string,integer>(); counts.put('month_total',0); counts.put('month_total',counts.get['month_total']++);
it returns "initial term of field expression must concrete sobject: map"
instead needed do:
counts = new map<string,integer>(); counts.put('month_total',0); integer temp = 0; temp++; counts.put('month_total',temp);
is there way increment without needing variable?
replace
counts.put('month_total',counts.get['month_total']++);
with
counts.put('month_total',counts.get('month_total')++);
Comments
Post a Comment