English 中文(简体)
Groovy关闭 - 这代码中发生了什么?
原标题:Groovy closure - what is happening in this code?

作为一个初学者,我试图理解我继承的下列精妙守则:

maxCount = skillsDist.findAll {it.mValue.value >= 0 }.max { it.mValue.value }.mValue.value
minCount = skillsDist.findAll { it.mValue.value >= 0  }.min { it.mValue.value }.mValue.value

技能Dist 对象是指类型 Set<CalculatingResult> 的爪哇对象。每个 CalculatingResult 都有一个 int 字段

我所苦恼的部分是最高和最短时间后的关闭。显然,我猜它会从集中找到最低和最高值,但我需要修改这一点,不理解这一点感到不舒服。

谢谢!

最佳回答

findAll Iterater 上方的 set 。 它创建了一个新的 set , 并添加了值大于或等于0的所有元素。 最大操作在子集中横跨子集并搜索最大值 。

第二行相同(预期它会寻找最小值) 。

问题回答

暂无回答




相关问题
Closure/scope JavaScript/jQuery

I m trying to group some exisiting top-level functions inside a closure (to avoid polluting the global namespace) but I m not quite getting it to work. First, all the JS works outside my anonymous ...

Nested Lambdas in Python

I m a beginning python programmer, and I d like someone to clarify the following behavior. I have the following code: env = lambda id: -1 def add(id, val, myenv): return lambda x: val if x == ...

closures mean fully type-safe criteria?

combining closures (FCM) and generics, would it be possible to have fully type-safe criteria. // The following works without a cast as Foo.id is a long field. List<Long> ids = session....

Is nested XMLHttpRequests with multiple closures a good idea?

I have a Greasemonkey script which operates on a search results page at a video site. The function of the script is to take a javascript link that opens a new window with a flash player, jump through ...

How|Where are closed-over variables stored?

This is a question based on the article "Closing over the loop variable considered harmful" by Eric Lippert. It is a good read, Eric explains why after this piece of code all funcs will return the ...

Scope with a self-invoking function in Javascript

Take below code iterates over 6 input buttons and attaches an onclick event to every button that alerts the index number of the respective iteration: for (var i = 1; i < 6; ++i) { var but = ...