在Groovy中有什么办法吗?
发布时间:2020-12-14 16:23:34 所属栏目:大数据 来源:网络整理
导读:我想要一个会返回如下列表的代码: def list = ["RR","SS"]//code to get the output as [R,R,S,S] 我想出了这样的想法: def Ash = ["RR","as","RTY"]def listA = []for(i=0;iAsh.size();i++){ listA Ash[i].collect{ it as String }}AshNew = listA.flatte
我想要一个会返回如下列表的代码:
def list = ["RR","SS"] //code to get the output as [R,R,S,S] 我想出了这样的想法: def Ash = ["RR","as","RTY"] def listA = [] for(i=0;i<Ash.size();i++) { listA << Ash[i].collect{ it as String } } AshNew = listA.flatten() println AshNew // this prints [R,a,s,T,Y] which is what i needed.. 但我仍然想知道我们是否可以通过另一种方式在Groovy中使用类似的东西?由于我是Groovy的新手,我想了解更多Groovier解决方案!感谢您的回答! 解决方法
关于什么
Ash.join().split("").tail() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |