Question

I would like to iterate over a collection of data stored in an arbitrary data structure. The only interface I have is Iterable. Is this possible with StringTemplate?

<source:{e|e.stuff}>



class Source<HasStuff> implements Iterable<HasStuff> {
   // Implementation
}
Was it helpful?

Solution

The current release (4.0.7) supports Iterator, but not Iterable. For details, see the following method, which returns an Iterator for use in the mapping operation.

https://github.com/antlr/stringtemplate4/blob/4.0.7/src/org/stringtemplate/v4/Interpreter.java#L1112-L1132

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top