groovy

Does Groovy allow trailing comma in lists?


Does Groovy syntax allow trailing commas in lists? I.e.:

def my_list = ["apple", "banana", "telephone",]

Solution

  • Per the list literal examples in the documentation, yes it does:

    assert list == [5, 6, 9, 8,]           // trailing comma OK