pseudo
pseudo
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
ty anyways
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
:TERROR:
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
altho is actually wrong if Nullable<T> is also a value-type, i just meant a nullable value type with it
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
Nullable<int> is boxed int
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
sorry term for another lang
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
public TResult Result()
{
if (_result is null)
throw new Exception("Given result type is an error");

return (TResult) _result;
}
public TResult Result()
{
if (_result is null)
throw new Exception("Given result type is an error");

return (TResult) _result;
}
I.e. this would crash surely for int?
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
public class ParseResult<TResult, TError>
{
private readonly TResult? _result;
private readonly TError? _error;

private ParseResult(TResult? result, TError? error)
{
_result = result;
_error = error;
}

public bool IsError() => _error is not null;

public TResult Result()
{
if (_result is null)
throw new Exception("Given result type is an error");

return (TResult) _result;
}

public static ParseResult<TResult, TError> CreatedResult(TResult result)
=> new(result, default);

public static ParseResult<TResult, TError> CreateError(TError error)
=> new(default, error);
}
public class ParseResult<TResult, TError>
{
private readonly TResult? _result;
private readonly TError? _error;

private ParseResult(TResult? result, TError? error)
{
_result = result;
_error = error;
}

public bool IsError() => _error is not null;

public TResult Result()
{
if (_result is null)
throw new Exception("Given result type is an error");

return (TResult) _result;
}

public static ParseResult<TResult, TError> CreatedResult(TResult result)
=> new(result, default);

public static ParseResult<TResult, TError> CreateError(TError error)
=> new(default, error);
}
But how does this build fine with unconstrained type
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
I get what you were saying about the .Value stuff
15 replies
CC#
Created by pseudo on 10/18/2024 in #help
Any case where `TError` can't be boxed in example?
@pride century 젠젠 Sorry for ping but im actually still confused :TERROR:
15 replies