Groovy dot notation in lists

I do not understand the purpose of the next construct in Groovy.

Whenever you have a collection of materials, name it items, you can map an attribute by simply referring to this attribute in the collection, i.e.

items.prop == items.collect { it.prop }

This looks strange to me because I think that the first notation actually meant that I wanted to access the property of the collection object itself. Real cases of ambiguity may occur, for example

[[1,2,3],['cat', 'elephant']].size == 2

but in accordance with the previous notation, it should be equal [3, 2].

In addition, if the record of the record was not short enough, there is an operator *.with extended points, which is intended for use in this way:

[[1,2,3],['cat', 'elephant']]*.size = [3, 2]

? *. , *. , collect ?

+5

All Articles