Groovy的隐藏功能? [英] Hidden features of Groovy?
本文介绍了Groovy的隐藏功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 尝试限制回答到Groovy核心
- 每个答案的一个功能
- 给出功能的示例和简短描述,而不仅仅是文档链接
- 使用加粗标题作为第一行标记功能
另见:
- Python的隐藏功能 li>
- Ruby的隐藏功能
- Perl的隐藏功能
- < a href =https://stackoverflow.com/questions/15496/hidden-features-of-java> Java的隐藏功能
解决方案
使用spread-dot op erator
def animals = ['ant','buffalo','canary','dog']
assert animals.size()== 4
assert animals * .size()== [3,7,6,3]
这是 animals.collect {it.size()}
的快捷方式。
It seems like Groovy was forgotten in this thread so I'll just ask the same question for Groovy.
- Try to limit answers to Groovy core
- One feature per answer
- Give an example and short description of the feature, not just a link to documentation
- Label the feature using bold title as the first line
See also:
解决方案
Using the spread-dot operator
def animals = ['ant', 'buffalo', 'canary', 'dog']
assert animals.size() == 4
assert animals*.size() == [3, 7, 6, 3]
This is a shortcut for animals.collect { it.size() }
.
这篇关于Groovy的隐藏功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文