Let's implement a function which accepts 2 parameters and returns whichever one of them is larger than the other.
To achieve this, we'll need to use the if/else expression, like this:
Let's analyze the syntax of an if/else expression:
We begin with the positive outcome expression, followed by thekeyword. Then comes the condition expression, followed by the keyword. Lastly, we have the negative outcome expression.
The result of an if/else expression is its positive outcome expression if the condition was equal toor else the negative outcome, if the condition was equal to .
So, in our example, we're returningif it is larger than . Otherwise, we return .
As with all other expressions, if we were to pass, for exampleand , to the Max function, we could access the previous value of its result, using the time travel operator, like this:
This pretty much covers if/else expressions.
Next, let's learn about debugging QuantScript code.