<p>I'd like some sorthand for this:</p>

<pre><code>Map rowToMap(row) {
    def rowMap = [:];
    row.columns.each{ rowMap[it.name] = it.val }
    return rowMap;
}
</code></pre>

<p>given the way the GDK stuff is, I'd expect to be able to do something like:</p>

<pre><code>Map rowToMap(row) {
    row.columns.collectMap{ [it.name,it.val] }
}
</code></pre>

<p>but I haven't seen anything in the docs... am I missing something? or am I just way too lazy?</p>

I can't find anything built in... but using the ExpandoMetaClass I can do this:
```
```
ArrayList.metaClass.collectMap = {Closure callback->
    def map = [:]
    delegate.each {
        def r = callback.call(it)
        map[r[0]] = r[1]
    }
    return map
}
```
```
this adds the collectMap method to all ArrayLists... I'm not sure why adding it to List or Collection didn't work.. I guess that's for another question... but now I can do this...
```
```
assert ["foo":"oof", "42":"24", "bar":"rab"] ==
            ["foo", "42", "bar"].collectMap { return [it, it.reverse()] }
```
```
from List to calculated Map with one closure... exactly what I was looking for.
Edit: the reason I couldn't add the method to the interfaces List and Collection was because I did not do this:
```
```
List.metaClass.enableGlobally()
```
```
after that method call, you can add methods to interfaces.. which in this case means my collectMap method will work on ranges like this:
```
```
(0..2).collectMap{[it, it*2]}
```
```
which yields the map: [0:0, 1:2, 2:4]