A clearer description of the original problem#2188
Conversation
The original excercise instructs the learner to use the vector macro. It is easy to assume that the code needs to read from `a` which is not what is intended. The updated excercise introduces the syntax for initial array and vector contents and lets the learner figure out how to tweak initial values of a vector. This learning seems to be the original intent of the excercise.
| let a = [10, 20, 30, 40]; // Array | ||
| // You can define an array with the intitial values 10, 20, 30 and 40 like | ||
| // this: | ||
| let a = [10, 20, 30, 40]; // Array. Do not change! |
There was a problem hiding this comment.
The original example already shows it’s just array initialization, so it works well. Still, it might be good to see the maintainer’s opinion.
| // Use the vector macro. | ||
| // let v = ???; | ||
| // There is a similar way you can define a vector with initial values: | ||
| // let v = vec![10, 20, ???]; // Vector. Needs to be fixed |
There was a problem hiding this comment.
Both to_vec() and Vec::from compile, but the author just wanted vec![10, 20, 30, 40]. So I think the original is fine — let’s see the maintainer’s opinion.
foxfromworld
left a comment
There was a problem hiding this comment.
This is related to #2167.
|
I think this PR is over explaining stuff, but I can see how the current state is confusing to some. Duplicating the literals is not something people would do in a real code base, so the mind doesn't jump to that. Maybe it's a good idea to redesign the exercise a little, so the |
|
Resolved by #2397 |
The original excercise instructs the learner to use the vector macro. It is easy to assume that the code needs to read from
awhich is not what is intended.The updated excercise introduces the syntax for initial array and vector contents and lets the learner figure out how to tweak initial values of a vector. This learning seems to be the original intent of the excercise.