gpt4 book ai didi

groovy - Groovy 的隐藏功能?

转载 作者:行者123 更新时间:2023-12-03 05:14:45 26 4
gpt4 key购买 nike

看起来 Groovy 在这个帖子中被遗忘了,所以我只会向 Groovy 问同样的问题。

  • 尝试将答案限制为 Groovy 核心
  • 每个答案一个功能
  • 提供该功能的示例和简短描述,而不仅仅是文档链接
  • 使用粗体标题作为第一行来标记功能

另请参阅:

  1. Hidden features of Python
  2. Hidden features of Ruby
  3. Hidden features of Perl
  4. Hidden features of Java

最佳答案

使用散点运算符

def animals = ['ant', 'buffalo', 'canary', 'dog']
assert animals.size() == 4
assert animals*.size() == [3, 7, 6, 3]

这是 animals.collect { it.size() } 的快捷方式。

关于groovy - Groovy 的隐藏功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/303512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com