Functions
In this section we will define a function that takes two numerical inputs and returns a Boolean value indicating whether they are equal. We will also take a look at how to use the function.
Declaration
The following function is called equals
and it takes two parameters of type u64
(64-bit unsigned integers). It performs a comparison and implicitly returns the result of that comparison.
fn equals(first_parameter: u64, second_parameter: u64) -> bool {
first_parameter == second_parameter
}
Usage
The following is a way to use the function defined above.
let result_one = equals(5, 5); // evaluates to `true`
let result_two = equals(5, 6); // evaluates to `false`