We can pass "named arguments" in method calls, making the following equivalent:
We should allow the same notations for indices in the subscript notation:
Currently, it's not possible to use map entries or maps as indices for the subscript notation.
So the idea of this JIRA improvement is to allow this.
And people would be able to use a getAt(Map) method on their objects to have access to that notation.
Some further remarks:
- with method calls, it's even possible to use the foo.method a: 1, b: 2 notation, but of course, this is not possible with the subscript notation, as we need the square brackets
- an example of using that map as index idea is for example to represent text pointers or text selections in some document handling application:
- the sole drawback with map entries as indices is when we want to use variables for line numbers, as we have to use parens around the "key" so as not to have a textual key: