Velocity: Dereferencing a variable with a concatinated name -


i'm new velocity , couldn't find addressed problem, apologize if it's trivial. have following 200 variables.

  #set( $a1 = "apple", $b1 = "red", $a2 = "banana", $b2 = "yellow" ....         .... $a100 = "plum", $b100 = "purple) 

i want output fruit followed color. there way concatenate "a" , "b" each of numbers in range(1,100) , dereference variable? like

 #foreach( $i in [1..100])      #set( $fruit = "a{$i}")      #set( $color = "b{$i}")       fruit $fruit color $color.    #end 

i've tried many things, can ever manage output $a1 $b1 strings rather refer to. thanks!

#set ($d = '$') #set ($h = '#') #foreach ($i in [1..100])   #evaluate("${h}set(${d}fruit = ${d}a${i})")   #evaluate("${h}set(${d}color = ${d}b${i})")   fruit ${fruit} color ${color}. #end 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -