Methods

A variable that is a method is used to calculate a value based on parameters you give.

Suppose that programmers have put the method variable avg in the data model that can be used to calculate the average of numbers. If you give the 3 and 5 as parameters when you access avg, then you get the value 4.

The usage of methods will be explained later, but perhaps this example helps to understand what methods are:

The average of 3 and 5 is: ${avg(3, 5)}
The average of 6 and 10 and 20 is: ${avg(6, 10, 20)}
The average of the price of python and elephant is: ${avg(animals.python.price, animals.elephant.price)}  

this will output:

The average of 3 and 5 is: 4
The average of 6 and 10 and 20 is: 12
The average of the price of python and elephant is: 4999.5  

Page generated: 2006-03-15 13:49:01 GMT FreeMarker Manual -- For FreeMarker 2.3.6