Groovy简单再入门
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Groovy简单再入门相关的知识,希望对你有一定的参考价值。
以前试过,忘得差不多了,趁这次从JAVA一直撸到SERVLET,SPRING,GROOVY,GRAILS的机会,再弄一次吧。。。
def authors = [ "Peter Ledbrook", "Glen Smith" ] def quoteParts = [ ["Time", "waits", "for no man"], ["The roundhouse kick", "solves", "all problems"], ["Groovy", "is", "the bees knees"] ] for (i in 0..10) { def quote = createQuote(quoteParts, authors) println quote } String createQuote(List quoteParts, List authors) { def rand = new Random() def n = quoteParts.size() def m = authors.size() return quoteParts[rand.nextInt(n)][0] + ‘ ‘ + quoteParts[rand.nextInt(n)][1] + ‘ ‘ + quoteParts[rand.nextInt(n)][2] + ‘ by ‘ + authors[rand.nextInt(m)] }
以上是关于Groovy简单再入门的主要内容,如果未能解决你的问题,请参考以下文章