jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
60 stars 49 forks source link

Should map literal support variable reference as key? #161

Closed Thihup closed 2 years ago

Thihup commented 2 years ago

Currently, the spec only shows examples of the map literals using Strings:

2.2.3. Map Construction
Construct an instance of java.util.Map<Object,Object>.

2.2.3.1. Syntax
Map := '{' MapEntries '}'

MapEntries := (MapEntry (',' MapEntry)* )?

MapEntry := expression ':' expression

2.2.3.2. Example
{"one":1, "two":2, "three":3}

However, the MapEntry shows that the key is an expression, so it could mean that a variable could be used as a key. Is that right?

markt-asf commented 2 years ago

Correct. An expression can be used for the key and/or the value when defining a Map.