Equals Operator - Integer
Not Started

Let’s expand on the total contract value (TCV) example. Say you have an Integer named tcvActual and another Integer named tcvExpected. You want to know if these two values are equal.

Integer actualTCV = 4500; Integer expectedTCV = 4500;

Visually, we can tell these numbers are the same, but how will our Apex detect that? We can use the == operator to test for equality. This operator compares the left-hand side to the right-hand side and returns a Boolean value. If they’re equal, we’ll get back True, otherwise we’ll get False.

Integer actualTCV = 4500; Integer expectedTCV = 4500; Boolean tcvMatch = actualTCV == expectedTCV; // evaluates to True

The code above will compare actualTCV with expectedTCV to determine if there is an exact match. In this case, there is, so tcvMatch is set to true.

Integer tcv = 4500; Integer expectedTCV = 3214; Boolean tcvMatch = actualTCV == expectedTCV; // evaluates to False

Since these values are different, tcvMatch will be false.

Later, we’ll learn how we can use this true and false value to make a decision in our code.

Challenge

Check ifactualAmount is equal to the expectedAmount. Create a variable named doesAmountMatch to store the results.