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.
Ah, another shorter version of mine. Very good.
its also difficult to understand ternary operators logic at first sight.
for readability.
of course you could omit AS in this kata
I agree with the first comment, that this is no good practice. And I agree that if-else-if-constructs are also no good practice. But as you can see in the frist solution, the else is not even necessary. The result is very easy to read code. You haven't to be a programmer to understand that code. The point is you don't need to get used to it, but to chained ternary operators you have to.
Using chained ternary operators in a uniform way like here isn't bad practice either. It's very easy to grasp that the value literals are increasing upper bounds. Write the same as a chained if-else-if-construct has the advantage to be able to set breakpoints when debugging but also the disadvantage of a worse signal to noise ratio due to many ifs, elses and returns. I think the main reason people still prefer that even in simple cases like this one is that they're used to it. =)
Thanks for sharing this advice. I was thinking this was a clean way of doing it.
This comment is hidden because it contains spoiler information about the solution
It's been a while since I did this one, but I'm pretty sure I wanted the subtraction done first, not the multiplication.
This comment is hidden because it contains spoiler information about the solution
Nested ternary operators are a hell to maintain. Not a good practice.
Why need use 'AS', please explain?
super, short and clear
Java and C# version fixed.Try it again~
I disagree, us0rman; the point of Katas is to build your programming skills. Part of this skill set is writing understandable, maintainable code. Using this formula, the function of the code will never change; thus maintainence will never be necessary and as such; this is excellent use of a Kata.
This comment is hidden because it contains spoiler information about the solution
Loading more items...