The question is as simple as the title. How to check in Groovy that object is a list or collection or array? But can\'t find a simple way of checking it. Any ideas?
I use this to "arrayfy" an object, if its already a collection then it will return a copy, else wrap it in a list. So you don't need to check it while processing, it will be always a collection.
def arrayfy = {[] + it ?: [it]}
def list = arrayfy(object) // will be always a list