Groovy web console

subscribe to the feed Subscribe
to this
site

String to map

Published 1 month ago by fonsito
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def test = "foo:1.0.0,bar:2.0.0"

def map = test.split(",").collectEntries { entry -> 
     def duple = entry.split(":")   
     [(duple[0]): duple[1]]
}

map.size()

map.foo

map.bar