Examples of JadeIterableIF Iteration
The following example uses the most‑basic form of a JadeIterableIF‑based foreach instruction with no options or as clause. The method in this example would accept any parameter that implements the
displayValues(iterable: JadeIterableIF);
vars
any: Any;
begin
foreach any in iterable do
write any.display();
endforeach;
end;
The following example uses a
displayValuesReversed(iterable: JadeReverseIterableIF);
vars
any: Any;
begin
foreach any in iterable reversed do
write any.display();
endforeach;
end;
The following example uses a
writeEmployees(employees: JadeIterableIF);
vars
employee: Employee;
begin
foreach employee in employees as Employee do
write employee.name & ", " & employee.calculateAge.String & " years old.";
endforeach;
end;
The following example uses an implementor of the JadeIterableIF interface as the iterable‑expression on the foreach instruction. In this example, the FarmYard class implements JadeIterableIF but is not a subclass of the Collection class.
writeFarmStock(farmYard: FarmYard);
vars
animal: Animal;
begin
foreach animal in farmYard as Animal do
write animal.display();
endforeach;
end;
2020.0.01 and higher
