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.
Nice idea with while (count--) and the loop will be left when it reaches 0.
This kata confuses me a lot. Why is it forcing us to not use if statements to solve this problem? Using switch...case function throws out an error to the compiler which is not a best practice and shouldn't teach beginners to do it like that.
Haha why would this answer be on here if it's not a solution?
This function is not an error handler nor is it designed to scale.
This is neither clever, nor good practice. It might work for the given problem but every addition to this code will break it or force the person to rewrite it the normal way. -rep
The function is not designed to handle errors or scale. These things can be handled in separate function calls...
To handle the errors you suggest the original template function would have to be modified to have return type pointer (
double *
) or the errors would be handled before the function call.I think there are two problems here. First of all, the operators (add, subtract, multiply, divide) must correspond to execute the right operation. Yet only the first letter is evaluated.
This function would return a sum still if I passed in "append" as operator. Furthermore, there is no default return value. Should the operator argument not correspond with any of the given ones,
this function wouldn't return anything at all.
agree with wmwmw... code after a return would never be evaluated.
Thats actually not true, as return breaks the execution.
Since routine does not include the break statement in each case, all the examples are in case 'd', so it would not be a valid solution.