Zat*_*ath 4 salesforce map increment visualforce apex-code
有没有办法在不需要第二个变量的情况下增加地图中的值?
例如,这不起作用:
counts = new Map<string,integer>();
counts.put('month_total',0);
counts.put('month_total',counts.get['month_total']++);
Run Code Online (Sandbox Code Playgroud)
它返回"字段表达式的初始术语必须是具体的SObject:MAP"
相反,我需要这样做:
counts = new Map<string,integer>();
counts.put('month_total',0);
integer temp = 0;
temp++;
counts.put('month_total',temp);
Run Code Online (Sandbox Code Playgroud)
有没有办法增加而不需要额外的变量?
更换
counts.put('month_total',counts.get['month_total']++);
Run Code Online (Sandbox Code Playgroud)
同
counts.put('month_total',counts.get('month_total')++);
Run Code Online (Sandbox Code Playgroud)