How to split dict value into two parts

I have

def dict = [some_key : ['a', 'bc', 'd']]

I would like to split bcby band c, so after splitting the dict will look like this:

dict = [some_key : ['a', 'b', 'c', 'd']]

Is there a way to do this using the built-in methods?

+4
source share
1 answer

Here you go:

def dict = [some_key : ['a', 'bc', 'd']]
dict.some_key = dict.some_key.collect { it.collect{ it } }.sum()
println dict

collectcalled in Stringwill return a character List.

+4
source

Source: https://habr.com/ru/post/1589205/


All Articles