groovy学习4集合类型

代码
//list and map
myList = [1776, -1, 33, 99, 0, 928734928763]
println myList[
0]
println myList.size()

scores
= [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ]
println scores[
"Pete"]
println scores.Pete

scores[
"Pete"] = 3
println scores.Pete

emptyMap
= [:]
emptyList
= []

println emptyMap.size()
println emptyList.size()

suvMap = ["Acura MDX": "\$36,700", "Ford Explorer": "\$26,845"]
suvMap = ["Acura MDX": "\$36,700", "Ford Explorer": "\$26,845"]
if (suvMap["Hummer H3"] != null) {  
  println("A Hummer H3 will set you back " + suvMap["Hummer H3"]);
}
原文地址:https://www.cnblogs.com/xiziyin/p/1702488.html