And/Or

Let’s say I’m selling movie tickets and we give a discount to people under 18, as well as to people 65 and older. I’d like to write a function gets_discount(). I can state the requirement in almost-code as age < 18 OR age >= 65. Unfortunately, that OR isn’t real Rust code. Instead, it’s time to introduce the or operator, which is two pipes || (hold shift and hit the backslash key on most keyboards).

Exercise

Implement the gets_discount function correctly to make this program pass.

Get hands-on with 1200+ tech skills courses.