[英]Convert a List (long) into List(String ) in Grails2.4.3 (Groovy)
Post call gives data in the form of List<Long>
and now I have to convert it into List<String>
, so I used this approach for it: Post调用以List<Long>
的形式提供数据,现在我必须将其转换为List<String>
,所以我使用了这种方法:
deleteAvailablity.startDate.each {
startDateList.add(it.toString())
}
deleteAvailablity.startDate = startDateList
Is there any better approach than this? 有没有比这更好的方法?
Use the Spread Operator 使用Spread Operator
This simple construct should do the job: 这个简单的构造应该做的工作:
assert [1l, 2l, 3l]*.toString() == ['1', '2', '3']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.