Groovy web console

subscribe to the feed Subscribe
to this
site

ID Generator

Published 1 month ago by Ivan Zilotti with tags id generator closure
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def createIdGenerator(initialValue) {    
    id = initialValue
    return { id++ }
}
def taskIdGenerator = createIdGenerator(65536)
println(taskIdGenerator())
println(taskIdGenerator())
println(taskIdGenerator())