Skip to main content

One doc tagged with "expression"

View all tags

Using `if` in a `let` Statement

In the previous articles, we explored how if-else expressions can be used to control the flow of our program. Now, we're going to look at a particularly powerful feature of Rust: because if is an expression, we can use it on the right side of a let statement to conditionally assign a value to a variable.