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.
the lack of typing work on typescript ? should it say that the parameters are not typed ?
Out of curiosity based on how i refactored my solution, why is this more popular of a solution than return (cast) (a+b)? It seems declaring another variable, even a local one, is more work than needs to be done when you can just return the value.
Is there a best practice that says a declared local variable is less prone to bugs or is it just preference as ease of understanding?
a
andb
already are of the typebyte
, so casting them will not do anything. However, the addition operator+
returns anint
(as bytes are not necessarily used as numbers, soa + b
implicitly does is(int) a + (int) b
), hence we do need to cast the result.It is often considered bad practice to use exceptions as flow control, but honestly, in this case, I will make an exception as Java sort of forces your hand.
It is indeed. But as you said: excersise.
This comment is hidden because it contains spoiler information about the solution