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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -