def numbers = [0, 1, 2, 3, 4, 5] as Integer[]
assert '0 x 1 x 2 x 3 x 4 x 5' == numbers.join(' x ')
def objects = [new URL('http://www.mrhaki.com'), 'mrhaki', new Expando(name: 'mrhaki'), new Date(109, 10, 10)]
assert 'http://www.mrhaki.com,mrhaki,{name=mrhaki},Tue Nov 10 00:00:00 UTC 2009' == objects.join(',')
http://mrhaki.blogspot.hk/2009/10/groovy-goodness-join-elements-to-string.html
沒有留言:
張貼留言