3 ms·
I'm more surprised they went with a new built-in instead of making the compiler recognize something like m = make(map[A]B, cap(m)) just like it already reco
by yencabulator 4y ago
I'm more surprised they went with a new built-in instead of making the compiler recognize something like
m = make(map[A]B, cap(m))
just like it already recognized
for k := range m {
delete(m, k)
}
and many other similar idioms.
(cap because len is not quite the same -- note, cap is not currently defined on maps)
EDIT: Likely because that's an assigment on m, not a mutation of it, so it can't be done e.g. in a function that gets m as argument.