CONDITIONmust be a boolean expression. If the condition evaluates to
EXPRESSION1is used, otherwise,
EXPRESSION2is used. One other thing to note here is that both expressions in the if statement must be of the same type. For example, the statement:
Int, but the type of
[Char]- a string is simply a list of characters).
show– it is a method (function) from the
class Showand it is used to represent the value of a type as a string. Hence, it has the following type signature:
Double) are instances of the
Showclass which enables us to use the
showfunction and get their representation as a string:
trackScore, we consider the two cases where the given time is lower than the average time and when it is higher than the average time. But what if it is exactly the same?