#set

Establishes the value of a reference

Examples :

Single value :
    #set( $count = 0 ) ## number
    #set( $name = "foo" ) ## string
    #set( $flag = true ) ## boolean
    #set( $name = $var ) ## variable
    #set( $name = $person.firstName ) ## object property
    #set( $v = "abc${generator.version}zzz" ) ## parsed
    #set( $v = 'abc${generator.version}zzz' ) ## not parsed

Collections :
    #set( $v = [1,2,3,4] )
    #set( $v = [1..6] ) ## from 1 to 6
    #set( $v = ['a','b','c','d'] )
    #set( $v = ['a', $DOLLAR, $SHARP, 'd'] ) ## parsed
    #set( $v = ['a', '$DOLLAR', '$SHARP', 'd'] ) ## not parsed
    #set( $v = $entity.attributes )

    #foreach( $e in $v )
    . $e
    #end

Maps :
    #set ( $map = {"banana" : "good", "cream" : "bad"} )
    #foreach($key in $map.keySet() )
    $key : $map.get($key)
    #end

Simple arithmetic expression is allowed :
    #set( $foo = $value + 1 )
    #set( $foo = $value - 1 )
    #set( $foo = $foo + 1 )
    #set( $val = $foo * $bar )
    #set( $val = $foo / $bar )
    #set( $val = $foo % $bar )