You don't need to use new very often either, because for structs you
have &typename{...}.
> otherwise we could as well have defined map in a "collection" package, and
> use
> map := collection.map.New()
> right ?
You'd lose the polymorphism that the built-in map magically has.
Chris
--
Chris "allusive" Dollin
So, just as a side question related to make vs new :There's absolutely no hope that one day map could use the "named return parameter" feature easily like this :func WordCount(s string) (res map[string]int) {// need to res = make(map[string]int) here, which quite defeats the handy shortcut... at least that shortcut could recognize the "map" type and do a make instead of a new, since it's built-in...?
I personnally prefer to allocate memory only when it's absolutely
needed. Memory allocation is costly and there's no reason to perform a
make() if you want to return a nil map.
Rémy.