Jeff Beck
Jeff Beck

Reputation: 3938

Groovy as List Question

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 thought that [] was the empty list so there would be no need to have the as List

Upvotes: 6

Views: 2153

Answers (1)

mfloryan
mfloryan

Reputation: 7685

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

Upvotes: 7

Related Questions