我有以下我在 groovy 1.8 中编写的代码
someListOfLists.flatten().sort().unique()
我已经转移到 groovy 2.3.x,并且 eclipse(使用快照版本中的 Juno 的 e4.4 GroovyEclipse 插件)向我展示了 sort() 方法现在已被弃用sort(Collection<T> self)
,建议使用sort(Iterable<T> self)
.
我现在如何将这样的方法链接在一起以避免弃用警告?
我的想法是 flatten() 返回一个 ArrayList (它是一个 Iterable)它应该没问题。另外,我看到做
((Iterable) someListOfLists.flatten()).sort().unique()
删除警告,但看起来很难看。
那么这只是日食没有看到实际使用正确的排序,还是有其他方式来表达我的方法链?