mirror of
https://git.tesses.org/tesses50/crosslangextras.git
synced 2026-06-01 18:35:32 +00:00
39 lines
547 B
Plaintext
39 lines
547 B
Plaintext
class Result {
|
|
private isError=false;
|
|
private value=null;
|
|
|
|
public Result(value, isError)
|
|
{
|
|
this.value = value;
|
|
this.isError = isError;
|
|
}
|
|
|
|
static Error(value)
|
|
{
|
|
return new Result(value,true);
|
|
}
|
|
|
|
static OK(value)
|
|
{
|
|
return new Result(value,false);
|
|
}
|
|
|
|
|
|
|
|
public getIsError()
|
|
{
|
|
return this.isError;
|
|
}
|
|
|
|
public getValue()
|
|
{
|
|
return this.value;
|
|
}
|
|
|
|
|
|
public Unwrap()
|
|
{
|
|
if(isError) throw value;
|
|
return value;
|
|
}
|
|
} |