[ 
https://issues.apache.org/jira/browse/VELOCITY-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660200#action_12660200
 ] 

Byron Foster commented on VELOCITY-406:
---------------------------------------

Added the $foo[1] style syntax.  When reading the value it's implemented by 
calling .get(<val>), so that the bracketed syntax is synonymous with .get(. 
This means it also works for getting Map values like $foo["junk"]. 

The setting this type of reference also works. for example:

#set($foo[2] = 3)

If the index value is an Integer, then it calls .set(Integer, <val>), otherwise 
it calls .put(<val>, <val>) which allows the setting of Map values with:

#set($foo["garbage"] = "smelly")



> Improved Syntax for Maps and Collections
> ----------------------------------------
>
>                 Key: VELOCITY-406
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-406
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I would like to see some syntatic sugar for Maps and Collections and perhaps 
> other Objects too. 
> (I have read that there will be a syntax for map literals in 1.5, that's a 
> first step.)
> I want to have something like in groovy: 
> http://groovy.codehaus.org/Collections
> Scroll down to "Slicing with the subscript operator".
> PS: Please do never implement this terrible confusing groovy map bean syntax, 
> where "map.foo" ist equivalent to "map.get("foo")".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to