API / Apache Velocity Interview questions
What are formal vs shorthand references in VTL?
Shorthand references, like $user or $user.name, are the everyday form and work fine as long as no adjacent text would be mistaken for part of the identifier.
Formal references wrap the variable name in braces, like ${user.name}, which explicitly marks where the reference ends. This matters when a reference is followed directly by more text with no separator:
report_$date.txt ## ambiguous: is ".txt" part of the reference? report_${date}.txt ## unambiguous
Functionally the two forms resolve identically; formal notation exists purely to disambiguate where shorthand would otherwise be misread by the parser.
More Related questions...