[stringtemplate-interest] The length of things
Terence Parr
parrt at cs.usfca.edu
Mon May 9 23:07:28 PDT 2005
On May 9, 2005, at 9:12 PM, Tom Bentley wrote:
> Hi All,
>
> I have a getFoo() method in my model which returns an array. I was
> sort of expecting that I could access the length of this array in
> StringTemplate using something along the lines of:
>
> $obj.foo.length$
>
> However, this doesn't work: I get a NoSuchField exception because
> length is supposedly not a field of the thing returned by getFoo().
>
Yup, you need to have a getLength() method I'm afraid. For size, it
would be convenient to answer size of array but also size of string.
The problem is that it's ambiguous. it would also be yet another
place where a type would have to be assumed to resolve the
ambiguity. But, I'm not ncessarily totally opposed.
Ter
More information about the stringtemplate-interest
mailing list