开发者

Groovy as List Question

开发者 https://www.devze.com 2023-03-04 08:23 出处:网络
I ran across this bit of code and to me it seems like its not needed is there any reason to do the following

I ran across this bit of code and to me it seems like its not needed is there any reason to do the following

def answers = [] as List

instead of

def answers = []

In groovy I though开发者_如何学Pythont that [] was the empty list so there would be no need to have the as List


No, there is no difference, both create an ArrayList and List (java.util.List) is an interface anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消