From the course: Rust Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Comparison operations

Comparison operations - Rust Tutorial

From the course: Rust Essential Training

Start my 1-month free trial

Comparison operations

- [Teacher] Another set of operators that can be used to evaluate two values and return a Boolean result are the comparison operators shown here. Operating on integers a and b, declared on lines two and three. The equality comparison operator on line five is represented using two equals symbols. It compares the values on each side of the operator and if they're equivalent the expression evaluates to true. Otherwise, if they're different values it evaluates to false. The non equality comparison operator below that on line six, which is an exclamation mark and an equals sign, operates in a similar but opposite fashion. If variables a and b are equivalent it will evaluate to false, and if they're different it will evaluate to true. The greater than, and greater than or equals comparisons on lines seven and eight work the way you might expect. If the value of integer a is greater than b the expression will evaluate to true,…

Contents