Rip switch statements
I can’t believe he needs that much code for this:
bool iseven(int number){ if (number % 2 == 0){ return true; } else { return false; } }
I like the example in the post better. It is more clear as to what is going on to an experienced dev like me. What’s this 2 percent nonsense?
Explanation: the percent is modulus. Basically it’s just divide the first number by the second and return the remainder. If you do number % 2, it will return 1 if it is odd and 0 if it is even. For example 4/2 has a remainder of 0 and therefore is even. 3/2 has a remainder of 1, and therefore is odd.
I like the example in the comment better. It is more confusing as to what is going on to an experienced dev like me. iSeven is always odd tho right?
It’s not obscure. This is the example, with syntactic differences, for this problem in almost every programming book I’ve read. He just didn’t include newlines.
I, EvaX, humbly submit a toast to Nicholas Alexander for successfully managing to pirate WarCraft III so that he may play Defense of the Ancients.
Congratulations Nick. Enjoy your DotA!
(sips from milk goblet)