groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: getAt inconsistence
Date Mon, 25 Jul 2016 19:53:09 GMT
On 23.07.2016 14:52, OC wrote:
> Hello there,
> is this the assumed behaviour? As always I might be missing something of importance,
but I would expect, when overriding getAt, that it simply gets called with the appropriate
argument for "foo[bar]" expressions.
> Instead, alas, for strings and gstrings, getAt is not called at all. I have found getProperty
is called instead, which seems wrong: far as I understand the documentation (and, well, also
simply by common sense) I should get getProperty for "", but getAt for "me['foo']",
should I not?

We have a method in DGM:

> public static Object getAt(Object self, String property) {
>   return InvokerHelper.getProperty(self, property);
> }

meaning Object itself provides a getAt method that uses getProperty - 
well, actually it is equal to self.$property. Which of course means if 
you add a getAt(Object) method and call this with a String or GString, 
we still call the above method. Which also explains your problem ;)

bye Jochen

View raw message