From 87ede6d2c0d2e6eca948a916e4c63f0f17c2bc22 Mon Sep 17 00:00:00 2001 From: tr00d Date: Mon, 18 Sep 2023 08:45:26 +0200 Subject: [PATCH 1/2] Simiplify ternary operator in Result --- Vonage.Common/Monads/Result.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Vonage.Common/Monads/Result.cs b/Vonage.Common/Monads/Result.cs index fc84f8912..487b91783 100644 --- a/Vonage.Common/Monads/Result.cs +++ b/Vonage.Common/Monads/Result.cs @@ -204,7 +204,9 @@ public void Match(Action successOperation, Action failureOper public Result Merge(Result other, Func merge) => this.IsSuccess && other.IsSuccess ? Result.FromSuccess(merge(this.success, other.success)) - : Result.FromFailure(this.IsFailure ? this.failure : other.failure); + : Result.FromFailure(this.FetchFailure(other)); + + private IResultFailure FetchFailure(Result other) => this.IsFailure ? this.failure : other.failure; /// /// Implicit operator from TA to Result of TA. From c815bda9190e332d8e1b93af0b65a078d068c0cb Mon Sep 17 00:00:00 2001 From: tr00d Date: Mon, 18 Sep 2023 08:45:26 +0200 Subject: [PATCH 2/2] Simplify ternary operator in Result --- Vonage.Common/Monads/Result.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Vonage.Common/Monads/Result.cs b/Vonage.Common/Monads/Result.cs index fc84f8912..487b91783 100644 --- a/Vonage.Common/Monads/Result.cs +++ b/Vonage.Common/Monads/Result.cs @@ -204,7 +204,9 @@ public void Match(Action successOperation, Action failureOper public Result Merge(Result other, Func merge) => this.IsSuccess && other.IsSuccess ? Result.FromSuccess(merge(this.success, other.success)) - : Result.FromFailure(this.IsFailure ? this.failure : other.failure); + : Result.FromFailure(this.FetchFailure(other)); + + private IResultFailure FetchFailure(Result other) => this.IsFailure ? this.failure : other.failure; /// /// Implicit operator from TA to Result of TA.