Array of strings in groovy

Lucas picture Lucas · Feb 18, 2010 · Viewed 157.2k times · Source

In ruby, there is a indiom to create a array of strings like this:

names = %w( lucas Fred Mary )

Is there something like that in groovy?

Answer

Dónal picture Dónal · Feb 18, 2010

If you really want to create an array rather than a list use either

String[] names = ["lucas", "Fred", "Mary"]

or

def names = ["lucas", "Fred", "Mary"].toArray()