A few new concepts are needed for this SKB.
First, what is a Boolean
? A Boolean
can only take two values: true
or false
. It is the result of a mathematical question. For instance, is 2 less than 5 (2 < 5
), it would returns "yes" (true
).
And from previous SKB, you might have noticed that assert
tests if what is inside is true
.
In Scala, and in the majority of other programming languages, you have a series of built-in comparators for mathematics:
==
: for equality. Some tips here: ==
. With only one =
, it would be an assignation (Like in: val a = 2
).1.5632426546
, they are called Double
or Float
) because the computer will round those numbers. So instead of a == b
, you should be doing something like: Math.abs(a - b) < 0.01
.!=
: Not equal>
: Greater than<
: Less than>=
: Greater than or equal<=
: Less than or equal