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.
If you don't want to copy the parameter (time and memory constraints), but want to use it without altering it, you pass it by const reference.
if you don't want to change number you shouldn't pass it as a reference
Because he is passing
number
as a reference.This would mean if he would change
number
in the body ofopposite
, the value would be also manipulated outside the function.This is clearly not wanted.
const
declares that number will be treated as constant in this function and has two purposes:number
as a reference, it will not be changedopposite
can not accidently changenumber
as this would result into a compilation error.Lol! Hilarious :)
So you allocate and initialize a vector and 4 strings just to throw them away in a moment, definitely not a best practice.
I love the simplicity. Taking notes.
Thanks for this solution. I'm studying it :)
I need to research your solution. Unfamiliar concepts, to me. Thanks!
LOL!
What's the benefit of making the function take a const int?
I only didn't because I've never heard of it, lol. Had I, I would've definitely mentioned it! :)
Amazing! I'm going to learn so much from your code. Thanks! Looks really clean.
Thanks for showing me how to use the ? conditional operator! You are amazing!
Finally! Using C++ I was stumped on how to return two string literals, lol. I was going to try a std::tuple, but that seemed like overkill, I guess.
Anyway, I finally got it! :)
Looking at the solutions, I found out how to return two different string literals.
Python test reference
https://www.codewars.com/docs/python-test-reference-1
Loading more items...