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"]);
}

 

posted @ 2010-04-01 17:50  雪霁霜飞  阅读(262)  评论(0编辑  收藏  举报