         var errorMessage: ExpectationMessage =
             .expectedActualValueTo("equal <\(stringify(expectedValue))>")
 
-        if let expectedValue = expectedValue {
-            if let actualValue = try actualExpression.evaluate() {
-                errorMessage = .expectedCustomValueTo(
-                    "equal <\(stringify(expectedValue))>",
-                    "<\(stringify(actualValue))>"
-                )
-
-                if expectedValue == actualValue {
-                    return PredicateResult(
-                        status: .matches,
-                        message: errorMessage
-                    )
-                }
-
-                let missing = expectedValue.subtracting(actualValue)
-                if missing.count > 0 {
-                    errorMessage = errorMessage.appended(message: ", missing <\(stringify(missing))>")
-                }
-
-                let extra = actualValue.subtracting(expectedValue)
-                if extra.count > 0 {
-                    errorMessage = errorMessage.appended(message: ", extra <\(stringify(extra))>")
-                }
-                return  PredicateResult(
-                    status: .doesNotMatch,
-                    message: errorMessage
-                )
-            }
+        guard let expectedValue = expectedValue else {
             return PredicateResult(
                 status: .fail,
                 message: errorMessage.appendedBeNilHint()
             )
-        } else {
+        }
+
+        guard let actualValue = try actualExpression.evaluate() else {
             return PredicateResult(
                 status: .fail,
                 message: errorMessage.appendedBeNilHint()
             )
         }
+
+        errorMessage = .expectedCustomValueTo(
+            "equal <\(stringify(expectedValue))>",
+            "<\(stringify(actualValue))>"
+        )
+
+        if expectedValue == actualValue {
+            return PredicateResult(
+                status: .matches,
+                message: errorMessage
+            )
+        }
+
+        let missing = expectedValue.subtracting(actualValue)
+        if missing.count > 0 {
+            errorMessage = errorMessage.appended(message: ", missing <\(stringify(missing))>")
+        }
+
+        let extra = actualValue.subtracting(expectedValue)
+        if extra.count > 0 {
+            errorMessage = errorMessage.appended(message: ", extra <\(stringify(extra))>")
+        }
+        return  PredicateResult(
+            status: .doesNotMatch,
+            message: errorMessage
+        )
     }
 }
 

public func equal<T, C: Equatable>(_ expectedValue: [T: C]?) -> Predicate<[T: C]> {
    return Predicate.define("equal <\(stringify(expectedValue))>") { actualExpression, msg in
        let actualValue = try actualExpression.evaluate()
        if expectedValue == nil || actualValue == nil {
            if expectedValue == nil && actualValue != nil {
                return PredicateResult(
                    status: .fail,
                    message: msg.appendedBeNilHint()
                )
            }
            return PredicateResult(status: .fail, message: msg)
        }
        return PredicateResult(
            status: PredicateStatus(bool: expectedValue! == actualValue!),
            message: msg
        )
    }
}


public func equal<T: Equatable>(_ expectedValue: T?) -> Predicate<T> {
    return Predicate.define("equal <\(stringify(expectedValue))>") { actualExpression, msg in
        let actualValue = try actualExpression.evaluate()
        switch (expectedValue, actualValue) {
        case (nil, _?):
            return PredicateResult(status: .fail, message: msg.appendedBeNilHint())
        case (nil, nil), (_, nil):
            return PredicateResult(status: .fail, message: msg)
        case (let expected?, let actual?):
            let matches = expected == actual
            return PredicateResult(bool: matches, message: msg)
        }
    }
}

