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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -