|
|
|
|
|
by typesanitizer
1511 days ago
|
|
> Some complaints also seem like a lack of experience using the language. > In my experience, the two-value (explicit capacity) form of "make" is significantly _less_ common than the single-value form. Indeed, gripping through the stdlib shows "make([]T, n) is much more common than "make([]T, n, m)". I've written a fair bit of C++, where this pattern is very common. IME in 95%+ of the cases, what one wants is a vector with a capacity without initializing it, because it will be filled up right away. I'd argue that make([]T, n) is more common in actual Go code precisely because it has the shorter spelling, not because it has the exact desired semantics. |
|
In C++ I'd write something like
but in Go I'd write Just like in Rust I might use iter().collect() or whatever.