You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we have extension methods that allow mapping between different types within Result. However, there's no straightforward way to map a Result to a non-generic Result (i.e., without T). I propose adding a new Map extension method to handle this scenario.
Problem:
When working with the Result class, there are cases where we want to discard the value T and map it to a non-generic Result. This is useful when we care about the success or failure state of the operation but no longer need to carry forward the result value.
Proposed Solution:
Add an extension method to the Result class that allows mapping from Result to Result. This extension method will preserve the success or failure status, as well as any errors, but will discard the underlying value T.
This will make it easier to handle cases where the result value is no longer needed, and we only care about whether the operation succeeded or failed.
Benefits:
Provides a clean and reusable way to convert Result to Result.
Keeps the codebase cleaner by removing the need for custom mapping logic in different parts of the code.
The text was updated successfully, but these errors were encountered:
I also have added an extension method to my code to handle this but as you said if the library had it, it would be better. Also it's a simple addition.
I've attached my PR to this, feel free to review and compare with your extension method.
I agree that this would be useful and as the contributor of Map this probably should have been included from it’s introduction. I will give @jmrtnz94 ‘s PR a review today.
Summary:
Currently, we have extension methods that allow mapping between different types within Result. However, there's no straightforward way to map a Result to a non-generic Result (i.e., without T). I propose adding a new Map extension method to handle this scenario.
Problem:
When working with the Result class, there are cases where we want to discard the value T and map it to a non-generic Result. This is useful when we care about the success or failure state of the operation but no longer need to carry forward the result value.
Proposed Solution:
Add an extension method to the Result class that allows mapping from Result to Result. This extension method will preserve the success or failure status, as well as any errors, but will discard the underlying value T.
Sample ### Method Signature:
This will make it easier to handle cases where the result value is no longer needed, and we only care about whether the operation succeeded or failed.
Benefits:
Provides a clean and reusable way to convert Result to Result.
Keeps the codebase cleaner by removing the need for custom mapping logic in different parts of the code.
The text was updated successfully, but these errors were encountered: