You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a common beginner's problem to create a vector with run-time size filled with identical values, but the idiomatic solution is pretty much undiscoverable without asking people on IRC/StackOverflow/Reddit.
It's already covered in the book at least, and I thought in some of these places too. Duplicating thing everywhere isn't the answer, though. If it's not on the macro or std::vec docs, it should be, though.
@steveklabnik
Duplication is necessary in this case because the syntax is "exotic" and not easily discoverable, it's not a normal method which everyone knows where to find.
Also, size with runtime value has to be actually used in an example and not only mentioned in text (that's what I meant by "highly visible").
The book doesn't count because nobody starts searching in the book when met with a question "How do I create a vector of N elements?", people try to look up it in the reference (in the method list of Vec, primarily).
It's a common beginner's problem to create a vector with run-time size filled with identical values, but the idiomatic solution is pretty much undiscoverable without asking people on IRC/StackOverflow/Reddit.
cc @steveklabnik
The text was updated successfully, but these errors were encountered: