Cambio en Maybe

This commit is contained in:
David Arranz 2025-11-05 18:17:12 +01:00
parent d55dee448b
commit b9ce356aa5

View File

@ -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;
}