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
I was wondering why there is no common base class or something like it, that allows one to use all similar functionalities of Result and Result.
I would like to do something like this:
public static T2 DoIfSuccess<T1, T2>(T1 input, Func function)
where T1 : IResultBase
where T2 : IResultBase
{
if (input.IsFailed) return input.ToResult();
var output = function();
return output.IsSuccess
? output
: input.ToResult();
}
It seems not to be possible at the moment, because T1 and T2 can not be converted into one another, but it should be possible in case of Result.Fail, because I don't need the value here.
Am I missing something? Why is this not possible currently and should it be possible?
The text was updated successfully, but these errors were encountered:
Hi,
I was wondering why there is no common base class or something like it, that allows one to use all similar functionalities of Result and Result.
I would like to do something like this:
public static T2 DoIfSuccess<T1, T2>(T1 input, Func function)
where T1 : IResultBase
where T2 : IResultBase
{
if (input.IsFailed) return input.ToResult();
var output = function();
return output.IsSuccess
? output
: input.ToResult();
}
It seems not to be possible at the moment, because T1 and T2 can not be converted into one another, but it should be possible in case of Result.Fail, because I don't need the value here.
Am I missing something? Why is this not possible currently and should it be possible?
The text was updated successfully, but these errors were encountered: