ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

Allow initialization of FHashMap with [:] syntax #356

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Like         
FHashMap map = [11:-1, 10:12, 4:5]// 
FHashMap.emptyMap.put(11,-11).put(10,12).put(4,5)

Original issue reported on code.google.com by alex.tka...@gmail.com on 20 Mar 2011 at 6:20

GoogleCodeExporter commented 8 years ago
that'd be awesome :)

Original comment by wmacgy...@gmail.com on 21 Mar 2011 at 7:05

GoogleCodeExporter commented 8 years ago
You can do

@Typed package p

FHashMap map = [10:12, 'a':45]
assert map[10] == 12
assert map.a== 45

def map2 = (FHashMap)[10:12, 'a':45]
assert map2[10] == 12
assert map2.a== 45

FHashMap mutate(FHashMap m) {
    m.put(10, 11)
}

assert mutate([10:15])[10] == 11

Original comment by alex.tka...@gmail.com on 21 Mar 2011 at 12:53