Q:

Convert array of string in array on long with closure

I have this string:
String t="123;123;123"

And I want to convert it in a list of Long, what I did so far is this:
t.split(";")

Which gives me back an array of String, now I'd like to convert it in an array of Long. I'd like to know if there is a way to do it with clousure instead of looping the array and move every single converted element in a new array.
thanks

A:

You are looking for Collection#collect.
t.split(";").collect { it.toLong() }

Does what you want. 
Try it: https://groovyconsole.appspot.com/script/5172355898802176

