Feature Overview
This feature adds array access support to maps.
This feature adds array access support to maps.
None
public class MapAccess {
public static void main() {
Map count = new Map{ 'a' => 2 };
Integer i = count['a'];
++count['a'];
count['a']++;
count['a'] += 2;
List nums = new List{ 2 };
Integer j = nums[0];
++nums[0];
nums[0]++;
nums[0] += 2;
}
}
public class MapAccess {
public static void main() {
Map count = new Map{ 'a' => 2 };
Integer i = count.get('a');
count.put('a', count.get('a') + 1);
count.put('a', count.get('a') + 1);
count.put('a', count.get('a') + 2);
List < Integer > nums = new List{ 2 };
Integer j = nums[0];
++nums[0];
nums[0]++;
nums[0] += 2;
}
}
Array access for maps support assignment expressions, postfix expressions, and prefix expressions.
Postfix and prefix expressions of map access cannot be used in assignments.
Contribute on Github! Edit this section.