How to count mobile objects?

Hello,

I would like to know how to count mobile objects. For example: I have a list, and I want to count the number of items within the list.

Thank you very much!

For further actions to list, you should refer to Groovy Documentations here. They have all the information you need to do with the list.

Hi there,

Counting the number of items within a list is easy:

list.size()

=> Count all items in the list

list.count()

=> Count specific items in the list

Example:
def list = [``0``, 1``, 2``, 1``, 1``, 3``, 2``, 0``, 1``]

assert 9 == list.``size``()
assert 2 == list.``count``(``0``)
assert 4 == list.``count``(``1``)
assert 2 == list.``count``(``2``)
assert 1 == list.``count``(``3``)
Thanks