Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Functions [7/9]

Since the execution of a function is completed when the return statement is executed, the function IsBetween can be written in this shorter way.

Commented out at the bottom is an even shorter way to write function IsBetween. To explain it, let's say that parameter a=3, b=7, x=10. The result of the function is the value of expression a<x and x<b. In this case, the expression a<x and x<b evaluates to false. Therefore, the value false is the return value of the function when a=3, b=7, x=10.

Loading...