Using spread operator, you can spread the elements of a list.
HelloWorld.groovy
def evenNumbers = [2, 4, 6, 8] def oddNumbers = [1, 3, 5, 7] def primeNumbers = [2, 3, 5, 7, 11] def allElements = [0, *evenNumbers, *oddNumbers, *primeNumbers] println allElements
Output
[0, 2, 4, 6, 8, 1, 3, 5, 7, 2, 3, 5, 7, 11]
No comments:
Post a Comment