Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Fixed by OP
Approved
python new test framework is required. updated in this fork
Python: Random tests are vulnerable to input modification
A reasonable optimizing compiler will produce the same machine code regardless of whether the variable is defined before the if-check or after it. Initializing local variables has no effects visible to callers so the compiler may freely reorder the code as it sees fit.
The reason is just style and clarity. First of all, it's common to add preconditions to the start of a function. If there are no items, we already know the answer and we can return right away. Second, it's generally a good idea to keep the scope of variables as small as possible.
Of course, in such a short function it doesn't really matter, but if a long function defines variable in the very beginning and uses it a lot later, can you be sure that there are no uses between? You have to carefully read through the whole function to check if there are other references.
This comment is hidden because it contains spoiler information about the solution
Sorry for thr late reply, I didn't receive your comment :<
Now it should be valid on
1.6
Oh yeah, I didn't notice that translation hadn't the latest language (maybe because I thought the
1.x
should include every single version of Rust starting with1.x
). FixedThanks. You must also select the latest version 1.6. Currently I see
1.x
, which is weird.Removed 'mut' from the string in question, now there shouldn't be any warnings here :)
In addition, there should not be any warnings:
There is
require
only formodifier
in the comment:But there's no require in the comment of
sendGift
buf only if:This is just an old answer, so its had a long time to slowly accumulate votes. There's no generic upvote, you either vote for best practice or clever, and this is definitely NOT clever.
It's also rust, which very few people truly understand (certainly including me) so many people don't know what they're looking at.
That being said, I haven't ever used C and C++ only like 15 years ago, so this is more just general procedural language not really C/C++. But yeah, there are definitely more concise ways of doing this in rust, considering it's awesome methods on iterables.
Several upticks for 'Best Practices' which I don't understand. This is exactly a C/C++ solution transscribed into Rust, it works but is not idiomatic Rust. I'd therefore say NOT best practice.
The test cases now include random tests.
Loading more items...