We might decide to write something like, if num mod two is zero, then return true
otherwise return false. This will certainly work.
Let's explore that. I will run this so we can have it there.
Now, I can access the is even int function and say, hey, there's even four?
Yes, it is. How about three?
No, that's false. So our function works.
However, The function body here is three lines too
long. I don't actually need to use an if
statement. The issue here is that, num mod two equals
zero is already a Boolean expression. As we saw over here, four mod two = zero
produced the value true. I don't need to say if something is true,
then return true, Otherwise, if it wasn't true, return
false. I can actually come into this out and
replace it with a single line. I want to return a Boolean.
Num mod two equals zero produces a Boolean, so I can just do return num mod