Cambio en Maybe
This commit is contained in:
parent
d55dee448b
commit
b9ce356aa5
@ -12,7 +12,7 @@
|
||||
export interface IMaybe<T> {
|
||||
isSome(): boolean;
|
||||
isNone(): boolean;
|
||||
unwrap(): T | undefined;
|
||||
unwrap(): T;
|
||||
getOrUndefined(): T | undefined;
|
||||
map<U>(fn: (value: T) => U): IMaybe<U>;
|
||||
match<U>(someFn: (value: T) => U, noneFn: () => U): U;
|
||||
@ -41,7 +41,11 @@ export class Maybe<T> implements IMaybe<T> {
|
||||
return !this.isSome();
|
||||
}
|
||||
|
||||
unwrap(): T | undefined {
|
||||
unwrap(): T {
|
||||
if (this.value === undefined || this.value === null) {
|
||||
throw new Error("Tried to unwrap a None value");
|
||||
}
|
||||
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user