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.
I guess I didn't need to use that if statement for an empty array.
I really like these variations. Maybe I just have neanderthal brain but I find them so easy to read.
Thank you for your reply. Makes sense.
The test cases just never set arr to None, that's why there's no error. What they do though is setting arr to [], which is different than None.
But in general you're right. One should check if arr is None before iterating over it.
Newbie question here. I feel like I just completed a Kata where if you didn't check for if arr is None then it would throw an error. Why doesn't this throw an error if arr is None?
The most correct code that is convenient to debug.
that's why in my solution, identical to this one, i named it
amount
.This code seems to be 15% faster than the CrazyMerlyn answer.
How is this clever? The
Neg
trait is simply the overload trait that defines the behavior of the negation operator. Therefore, you should just use the actual negation operator.Ah, thanks. I thought they were saying that in-built functions and methods should be avoided :D
I guess Acmer77 means that the variable name
sum
should be avoided because its name is too similar to the function namedsum()
.why would you avoid built-in functions? I thought they were there to make your life easier.
This comment is hidden because it contains spoiler information about the solution
Hey! Just finished translating this Kata to Rust. Can anyone please review it at Exes and Ohs in Rust?